# HG changeset patch # User paulb # Date 1093554465 0 # Node ID bf79cd93cfcddb46b51ff42347588f4e41fb6bbd # Parent d4a528c5688f0456fecfb992f658e6615da02807 [project @ 2004-08-26 21:07:45 by paulb] Removed mentions of "framework-specific" in method docstrings, since this term could be misinterpreted as "non-standard" rather than as the intended meaning of "relying on framework functionality". diff -r d4a528c5688f -r bf79cd93cfcd WebStack/BaseHTTPRequestHandler.py --- a/WebStack/BaseHTTPRequestHandler.py Thu Aug 26 20:37:56 2004 +0000 +++ b/WebStack/BaseHTTPRequestHandler.py Thu Aug 26 21:07:45 2004 +0000 @@ -81,8 +81,7 @@ def get_request_stream(self): """ - A framework-specific method which returns the request stream for - the transaction. + Returns the request stream for the transaction. """ return MessageBodyStream(self.trans.rfile, self.get_headers()) @@ -90,7 +89,7 @@ def get_request_method(self): """ - A framework-specific method which gets the request method. + Returns the request method. """ return self.trans.command @@ -98,8 +97,9 @@ def get_headers(self): """ - A framework-specific method which returns all request headers as a - dictionary-like object mapping header names to values. + Returns all request headers as a dictionary-like object mapping header + names to values. + NOTE: If duplicate header names are permitted, then this interface will NOTE: need to change. """ @@ -109,9 +109,9 @@ def get_header_values(self, key): """ - A framework-specific method which returns a list of all request header - values associated with the given 'key'. Note that according to RFC 2616, - 'key' is treated as a case-insensitive string. + Returns a list of all request header values associated with the given + 'key'. Note that according to RFC 2616, 'key' is treated as a + case-insensitive string. """ return self.convert_to_list(self.trans.headers.get(key)) @@ -119,8 +119,8 @@ def get_content_type(self): """ - A framework-specific method which gets the content type specified on the - request, along with the charset employed. + Returns the content type specified on the request, along with the + charset employed. """ return self.parse_content_type(self.trans.headers.get("content-type")) @@ -136,8 +136,7 @@ def get_content_languages(self): """ - A framework-specific method which extracts language information from - the transaction. + Returns extracted language information from the transaction. """ return self.parse_content_preferences(self.trans.headers.get("accept-language")) @@ -145,7 +144,7 @@ def get_path(self): """ - A framework-specific method which gets the entire path from the request. + Returns the entire path from the request. """ return self.trans.path @@ -153,8 +152,7 @@ def get_path_without_query(self): """ - A framework-specific method which gets the entire path from the request - minus the query string. + Returns the entire path from the request minus the query string. """ # Remove the query string from the end of the path. @@ -164,9 +162,8 @@ def get_path_info(self): """ - A framework-specific method which gets the "path info" (the part of the - URL after the resource name handling the current request) from the - request. + Returns the "path info" (the part of the URL after the resource name + handling the current request) from the request. """ return self.get_path_without_query() @@ -174,8 +171,7 @@ def get_query_string(self): """ - A framework-specific method which gets the query string from the path in - the request. + Returns the query string from the path in the request. """ t = self.trans.path.split("?") @@ -192,9 +188,9 @@ def get_fields_from_path(self): """ - A framework-specific method which extracts the form fields from the - path specified in the transaction. The underlying framework may refuse - to supply fields from the path if handling a POST transaction. + Extracts the form fields from the path specified in the transaction. The + underlying framework may refuse to supply fields from the path if + handling a POST transaction. Returns a dictionary mapping field names to lists of values (even if a single value is associated with any given field name). @@ -205,11 +201,10 @@ def get_fields_from_body(self, encoding=None): """ - A framework-specific method which extracts the form fields from the - message body in the transaction. The optional 'encoding' parameter - specifies the character encoding of the message body for cases where no - such information is available, but where the default encoding is to be - overridden. + Extracts the form fields from the message body in the transaction. The + optional 'encoding' parameter specifies the character encoding of the + message body for cases where no such information is available, but where + the default encoding is to be overridden. Returns a dictionary mapping field names to lists of values (even if a single value is associated with any given field name). @@ -238,8 +233,7 @@ def get_user(self): """ - A framework-specific method which extracts user information from the - transaction. + Extracts user information from the transaction. Returns a username as a string or None if no user is defined. """ @@ -256,8 +250,7 @@ def get_cookies(self): """ - A framework-specific method which obtains cookie information from the - request. + Obtains cookie information from the request. Returns a dictionary mapping cookie names to cookie objects. """ @@ -267,8 +260,7 @@ def get_cookie(self, cookie_name): """ - A framework-specific method which obtains cookie information from the - request. + Obtains cookie information from the request. Returns a cookie object for the given 'cookie_name' or None if no such cookie exists. @@ -281,8 +273,7 @@ def get_response_stream(self): """ - A framework-specific method which returns the response stream for - the transaction. + Returns the response stream for the transaction. """ # Return a stream which is later emptied into the real stream. @@ -325,8 +316,7 @@ def set_content_type(self, content_type): """ - A framework-specific method which sets the 'content_type' for the - response. + Sets the 'content_type' for the response. """ # The content type has to be written as a header, before actual content, @@ -335,11 +325,12 @@ self.content_type = content_type + # Higher level response-related methods. + def set_cookie(self, cookie): """ - A framework-specific method which stores the given 'cookie' object in - the response. + Stores the given 'cookie' object in the response. """ # NOTE: If multiple cookies of the same name could be specified, this @@ -350,8 +341,7 @@ def set_cookie_value(self, name, value, path=None, expires=None): """ - A framework-specific method which stores a cookie with the given 'name' - and 'value' in the response. + Stores a cookie with the given 'name' and 'value' in the response. The optional 'path' is a string which specifies the scope of the cookie, and the optional 'expires' parameter is a value compatible with the @@ -367,9 +357,8 @@ def delete_cookie(self, cookie_name): """ - A framework-specific method which adds to the response a request that - the cookie with the given 'cookie_name' be deleted/discarded by the - client. + Adds to the response a request that the cookie with the given + 'cookie_name' be deleted/discarded by the client. """ # Create a special cookie, given that we do not know whether the browser diff -r d4a528c5688f -r bf79cd93cfcd WebStack/CGI.py --- a/WebStack/CGI.py Thu Aug 26 20:37:56 2004 +0000 +++ b/WebStack/CGI.py Thu Aug 26 21:07:45 2004 +0000 @@ -79,8 +79,7 @@ def get_request_stream(self): """ - A framework-specific method which returns the request stream for - the transaction. + Returns the request stream for the transaction. """ return self.input @@ -88,7 +87,7 @@ def get_request_method(self): """ - A framework-specific method which gets the request method. + Returns the request method. """ return self.env.get("REQUEST_METHOD") @@ -96,8 +95,8 @@ def get_headers(self): """ - A framework-specific method which returns all request headers as a - dictionary-like object mapping header names to values. + Returns all request headers as a dictionary-like object mapping header + names to values. """ return Environment.get_headers(self.env) @@ -105,9 +104,9 @@ def get_header_values(self, key): """ - A framework-specific method which returns a list of all request header - values associated with the given 'key'. Note that according to RFC 2616, - 'key' is treated as a case-insensitive string. + Returns a list of all request header values associated with the given + 'key'. Note that according to RFC 2616, 'key' is treated as a + case-insensitive string. """ return self.convert_to_list(self.get_headers().get(key)) @@ -115,8 +114,8 @@ def get_content_type(self): """ - A framework-specific method which gets the content type specified on the - request, along with the charset employed. + Returns the content type specified on the request, along with the + charset employed. """ return self.parse_content_type(self.env.get("CONTENT_TYPE")) @@ -132,8 +131,7 @@ def get_content_languages(self): """ - A framework-specific method which extracts language information from - the transaction. + Returns extracted language information from the transaction. """ return self.parse_content_preferences(None) @@ -141,7 +139,7 @@ def get_path(self): """ - A framework-specific method which gets the entire path from the request. + Returns the entire path from the request. """ path = self.get_path_without_query() @@ -154,8 +152,7 @@ def get_path_without_query(self): """ - A framework-specific method which gets the entire path from the request - minus the query string. + Returns the entire path from the request minus the query string. """ path = self.env.get("SCRIPT_NAME") or "" @@ -166,9 +163,8 @@ def get_path_info(self): """ - A framework-specific method which gets the "path info" (the part of the - URL after the resource name handling the current request) from the - request. + Returns the "path info" (the part of the URL after the resource name + handling the current request) from the request. """ return self.env.get("PATH_INFO") or "" @@ -176,8 +172,7 @@ def get_query_string(self): """ - A framework-specific method which gets the query string from the path in - the request. + Returns the query string from the path in the request. """ return self.env.get("QUERY_STRING") or "" @@ -187,9 +182,9 @@ def get_fields_from_path(self): """ - A framework-specific method which extracts the form fields from the - path specified in the transaction. The underlying framework may refuse - to supply fields from the path if handling a POST transaction. + Extracts the form fields from the path specified in the transaction. The + underlying framework may refuse to supply fields from the path if + handling a POST transaction. Returns a dictionary mapping field names to lists of values (even if a single value is associated with any given field name). @@ -200,11 +195,10 @@ def get_fields_from_body(self, encoding=None): """ - A framework-specific method which extracts the form fields from the - message body in the transaction. The optional 'encoding' parameter - specifies the character encoding of the message body for cases where no - such information is available, but where the default encoding is to be - overridden. + Extracts the form fields from the message body in the transaction. The + optional 'encoding' parameter specifies the character encoding of the + message body for cases where no such information is available, but where + the default encoding is to be overridden. Returns a dictionary mapping field names to lists of values (even if a single value is associated with any given field name). @@ -232,8 +226,7 @@ def get_user(self): """ - A framework-specific method which extracts user information from the - transaction. + Extracts user information from the transaction. Returns a username as a string or None if no user is defined. """ @@ -246,8 +239,7 @@ def get_cookies(self): """ - A framework-specific method which obtains cookie information from the - request. + Obtains cookie information from the request. Returns a dictionary mapping cookie names to cookie objects. """ @@ -257,8 +249,7 @@ def get_cookie(self, cookie_name): """ - A framework-specific method which obtains cookie information from the - request. + Obtains cookie information from the request. Returns a cookie object for the given 'cookie_name' or None if no such cookie exists. @@ -271,8 +262,7 @@ def get_response_stream(self): """ - A framework-specific method which returns the response stream for - the transaction. + Returns the response stream for the transaction. """ # Return a stream which is later emptied into the real stream. @@ -315,8 +305,7 @@ def set_content_type(self, content_type): """ - A framework-specific method which sets the 'content_type' for the - response. + Sets the 'content_type' for the response. """ # The content type has to be written as a header, before actual content, @@ -330,8 +319,7 @@ def set_cookie(self, cookie): """ - A framework-specific method which stores the given 'cookie' object in - the response. + Stores the given 'cookie' object in the response. """ # NOTE: If multiple cookies of the same name could be specified, this @@ -342,8 +330,7 @@ def set_cookie_value(self, name, value, path=None, expires=None): """ - A framework-specific method which stores a cookie with the given 'name' - and 'value' in the response. + Stores a cookie with the given 'name' and 'value' in the response. The optional 'path' is a string which specifies the scope of the cookie, and the optional 'expires' parameter is a value compatible with the @@ -359,9 +346,8 @@ def delete_cookie(self, cookie_name): """ - A framework-specific method which adds to the response a request that - the cookie with the given 'cookie_name' be deleted/discarded by the - client. + Adds to the response a request that the cookie with the given + 'cookie_name' be deleted/discarded by the client. """ # Create a special cookie, given that we do not know whether the browser diff -r d4a528c5688f -r bf79cd93cfcd WebStack/Generic.py --- a/WebStack/Generic.py Thu Aug 26 20:37:56 2004 +0000 +++ b/WebStack/Generic.py Thu Aug 26 21:07:45 2004 +0000 @@ -128,8 +128,7 @@ def get_request_stream(self): """ - A framework-specific method which returns the request stream for - the transaction. + Returns the request stream for the transaction. """ raise NotImplementedError, "get_request_stream" @@ -137,7 +136,7 @@ def get_request_method(self): """ - A framework-specific method which gets the request method. + Returns the request method. """ raise NotImplementedError, "get_request_method" @@ -145,8 +144,8 @@ def get_headers(self): """ - A framework-specific method which returns all request headers as a - dictionary-like object mapping header names to values. + Returns all request headers as a dictionary-like object mapping header + names to values. """ raise NotImplementedError, "get_headers" @@ -154,9 +153,9 @@ def get_header_values(self, key): """ - A framework-specific method which returns a list of all request header - values associated with the given 'key'. Note that according to RFC 2616, - 'key' is treated as a case-insensitive string. + Returns a list of all request header values associated with the given + 'key'. Note that according to RFC 2616, 'key' is treated as a + case-insensitive string. """ raise NotImplementedError, "get_header_values" @@ -164,8 +163,8 @@ def get_content_type(self): """ - A framework-specific method which gets the content type specified on the - request, along with the charset employed. + Returns the content type specified on the request, along with the + charset employed. """ raise NotImplementedError, "get_content_type" @@ -181,8 +180,7 @@ def get_content_languages(self): """ - A framework-specific method which extracts language information from - the transaction. + Returns extracted language information from the transaction. """ raise NotImplementedError, "get_content_languages" @@ -190,7 +188,7 @@ def get_path(self): """ - A framework-specific method which gets the entire path from the request. + Returns the entire path from the request. """ raise NotImplementedError, "get_path" @@ -198,8 +196,7 @@ def get_path_without_query(self): """ - A framework-specific method which gets the entire path from the request - minus the query string. + Returns the entire path from the request minus the query string. """ raise NotImplementedError, "get_path_without_query" @@ -207,9 +204,8 @@ def get_path_info(self): """ - A framework-specific method which gets the "path info" (the part of the - URL after the resource name handling the current request) from the - request. + Returns the "path info" (the part of the URL after the resource name + handling the current request) from the request. """ raise NotImplementedError, "get_path_info" @@ -217,8 +213,7 @@ def get_query_string(self): """ - A framework-specific method which gets the query string from the path in - the request. + Returns the query string from the path in the request. """ raise NotImplementedError, "get_query_string" @@ -228,9 +223,9 @@ def get_fields_from_path(self): """ - A framework-specific method which extracts the form fields from the - path specified in the transaction. The underlying framework may refuse - to supply fields from the path if handling a POST transaction. + Extracts the form fields from the path specified in the transaction. The + underlying framework may refuse to supply fields from the path if + handling a POST transaction. Returns a dictionary mapping field names to lists of values (even if a single value is associated with any given field name). @@ -241,11 +236,10 @@ def get_fields_from_body(self, encoding=None): """ - A framework-specific method which extracts the form fields from the - message body in the transaction. The optional 'encoding' parameter - specifies the character encoding of the message body for cases where no - such information is available, but where the default encoding is to be - overridden. + Extracts the form fields from the message body in the transaction. The + optional 'encoding' parameter specifies the character encoding of the + message body for cases where no such information is available, but where + the default encoding is to be overridden. Returns a dictionary mapping field names to lists of values (even if a single value is associated with any given field name). @@ -256,8 +250,7 @@ def get_user(self): """ - A framework-specific method which extracts user information from the - transaction. + Extracts user information from the transaction. Returns a username as a string or None if no user is defined. """ @@ -267,8 +260,7 @@ def get_cookies(self): """ - A framework-specific method which obtains cookie information from the - request. + Obtains cookie information from the request. Returns a dictionary mapping cookie names to cookie objects. """ @@ -278,8 +270,7 @@ def get_cookie(self, cookie_name): """ - A framework-specific method which obtains cookie information from the - request. + Obtains cookie information from the request. Returns a cookie object for the given 'cookie_name' or None if no such cookie exists. @@ -292,8 +283,7 @@ def get_response_stream(self): """ - A framework-specific method which returns the response stream for - the transaction. + Returns the response stream for the transaction. """ raise NotImplementedError, "get_response_stream" @@ -327,8 +317,7 @@ def set_content_type(self, content_type): """ - A framework-specific method which sets the 'content_type' for the - response. + Sets the 'content_type' for the response. """ raise NotImplementedError, "set_content_type" @@ -338,8 +327,7 @@ def set_cookie(self, cookie): """ - A framework-specific method which stores the given 'cookie' object in - the response. + Stores the given 'cookie' object in the response. """ raise NotImplementedError, "set_cookie" @@ -347,8 +335,7 @@ def set_cookie_value(self, name, value, path=None, expires=None): """ - A framework-specific method which stores a cookie with the given 'name' - and 'value' in the response. + Stores a cookie with the given 'name' and 'value' in the response. The optional 'path' is a string which specifies the scope of the cookie, and the optional 'expires' parameter is a value compatible with the @@ -360,9 +347,8 @@ def delete_cookie(self, cookie_name): """ - A framework-specific method which adds to the response a request that - the cookie with the given 'cookie_name' be deleted/discarded by the - client. + Adds to the response a request that the cookie with the given + 'cookie_name' be deleted/discarded by the client. """ raise NotImplementedError, "delete_cookie" @@ -372,8 +358,8 @@ def get_session(self, create=1): """ - A framework-specific method which returns a session corresponding to - an identifier supplied in the transaction. + Gets a session corresponding to an identifier supplied in the + transaction. If no session has yet been established according to information provided in the transaction then the optional 'create' parameter @@ -389,8 +375,8 @@ def expire_session(self): """ - A framework-specific method which expires any session established - according to information provided in the transaction. + Expires any session established according to information provided in the + transaction. """ raise NotImplementedError, "expire_session" diff -r d4a528c5688f -r bf79cd93cfcd WebStack/JavaServlet.py --- a/WebStack/JavaServlet.py Thu Aug 26 20:37:56 2004 +0000 +++ b/WebStack/JavaServlet.py Thu Aug 26 21:07:45 2004 +0000 @@ -79,8 +79,7 @@ def get_request_stream(self): """ - A framework-specific method which returns the request stream for - the transaction. + Returns the request stream for the transaction. """ return Stream(self.request.getReader()) @@ -88,7 +87,7 @@ def get_request_method(self): """ - A framework-specific method which gets the request method. + Returns the request method. """ return self.request.getMethod() @@ -96,8 +95,9 @@ def get_headers(self): """ - A framework-specific method which returns all request headers as a - dictionary-like object mapping header names to values. + Returns all request headers as a dictionary-like object mapping header + names to values. + NOTE: If duplicate header names are permitted, then this interface will NOTE: need to change. """ @@ -116,9 +116,9 @@ def get_header_values(self, key): """ - A framework-specific method which returns a list of all request header - values associated with the given 'key'. Note that according to RFC 2616, - 'key' is treated as a case-insensitive string. + Returns a list of all request header values associated with the given + 'key'. Note that according to RFC 2616, 'key' is treated as a + case-insensitive string. """ values = [] @@ -130,8 +130,8 @@ def get_content_type(self): """ - A framework-specific method which gets the content type specified on the - request, along with the charset employed. + Returns the content type specified on the request, along with the + charset employed. """ content_types = self.get_header_values("Content-Type") or [] @@ -155,8 +155,7 @@ def get_content_languages(self): """ - A framework-specific method which extracts language information from - the transaction. + Returns extracted language information from the transaction. """ accept_languages = self.get_header_values("Accept-Language") or [] @@ -168,7 +167,7 @@ def get_path(self): """ - A framework-specific method which gets the entire path from the request. + Returns the entire path from the request. """ # NOTE: To be verified. @@ -183,8 +182,7 @@ def get_path_without_query(self): """ - A framework-specific method which gets the entire path from the request - minus the query string. + Returns the entire path from the request minus the query string. """ return self.request.getServletPath() @@ -192,9 +190,8 @@ def get_path_info(self): """ - A framework-specific method which gets the "path info" (the part of the - URL after the resource name handling the current request) from the - request. + Returns the "path info" (the part of the URL after the resource name + handling the current request) from the request. """ return self.request.getPathInfo() @@ -202,8 +199,7 @@ def get_query_string(self): """ - A framework-specific method which gets the query string from the path in - the request. + Returns the query string from the path in the request. """ return self.request.getQueryString() @@ -213,9 +209,9 @@ def get_fields_from_path(self): """ - A framework-specific method which extracts the form fields from the - path specified in the transaction. The underlying framework may refuse - to supply fields from the path if handling a POST transaction. + Extracts the form fields from the path specified in the transaction. The + underlying framework may refuse to supply fields from the path if + handling a POST transaction. Returns a dictionary mapping field names to lists of values (even if a single value is associated with any given field name). @@ -229,11 +225,10 @@ def get_fields_from_body(self, encoding=None): """ - A framework-specific method which extracts the form fields from the - message body in the transaction. The optional 'encoding' parameter - specifies the character encoding of the message body for cases where no - such information is available, but where the default encoding is to be - overridden. + Extracts the form fields from the message body in the transaction. The + optional 'encoding' parameter specifies the character encoding of the + message body for cases where no such information is available, but where + the default encoding is to be overridden. Returns a dictionary mapping field names to lists of values (even if a single value is associated with any given field name). @@ -253,8 +248,7 @@ def get_user(self): """ - A framework-specific method which extracts user information from the - transaction. + Extracts user information from the transaction. Returns a username as a string or None if no user is defined. """ @@ -267,8 +261,7 @@ def get_cookies(self): """ - A framework-specific method which obtains cookie information from the - request. + Obtains cookie information from the request. Returns a dictionary mapping cookie names to cookie objects. """ @@ -278,8 +271,7 @@ def get_cookie(self, cookie_name): """ - A framework-specific method which obtains cookie information from the - request. + Obtains cookie information from the request. Returns a cookie object for the given 'cookie_name' or None if no such cookie exists. @@ -292,8 +284,7 @@ def get_response_stream(self): """ - A framework-specific method which returns the response stream for - the transaction. + Returns the response stream for the transaction. """ return self.response.getOutputStream() @@ -328,8 +319,7 @@ def set_content_type(self, content_type): """ - A framework-specific method which sets the 'content_type' for the - response. + Sets the 'content_type' for the response. """ return self.response.setHeader("Content-Type", self.format_content_type(content_type)) @@ -339,8 +329,7 @@ def set_cookie(self, cookie): """ - A framework-specific method which stores the given 'cookie' object in - the response. + Stores the given 'cookie' object in the response. """ new_cookie = javax.servlet.http.Cookie(cookie.name, cookie.value) @@ -349,8 +338,7 @@ def set_cookie_value(self, name, value, path=None, expires=None): """ - A framework-specific method which stores a cookie with the given 'name' - and 'value' in the response. + Stores a cookie with the given 'name' and 'value' in the response. The optional 'path' is a string which specifies the scope of the cookie, and the optional 'expires' parameter is a value compatible with the @@ -368,9 +356,8 @@ def delete_cookie(self, cookie_name): """ - A framework-specific method which adds to the response a request that - the cookie with the given 'cookie_name' be deleted/discarded by the - client. + Adds to the response a request that the cookie with the given + 'cookie_name' be deleted/discarded by the client. """ # Create a special cookie, given that we do not know whether the browser @@ -387,8 +374,8 @@ def get_session(self, create=1): """ - A framework-specific method which returns a session corresponding to - an identifier supplied in the transaction. + Gets a session corresponding to an identifier supplied in the + transaction. If no session has yet been established according to information provided in the transaction then the optional 'create' parameter @@ -404,8 +391,8 @@ def expire_session(self): """ - A framework-specific method which expires any session established - according to information provided in the transaction. + Expires any session established according to information provided in the + transaction. """ session = self.get_session(create=0) diff -r d4a528c5688f -r bf79cd93cfcd WebStack/ModPython.py --- a/WebStack/ModPython.py Thu Aug 26 20:37:56 2004 +0000 +++ b/WebStack/ModPython.py Thu Aug 26 21:07:45 2004 +0000 @@ -40,8 +40,7 @@ def get_request_stream(self): """ - A framework-specific method which returns the request stream for - the transaction. + Returns the request stream for the transaction. """ return self.trans @@ -49,7 +48,7 @@ def get_request_method(self): """ - A framework-specific method which gets the request method. + Returns the request method. """ return self.trans.method @@ -57,8 +56,9 @@ def get_headers(self): """ - A framework-specific method which returns all request headers as a - dictionary-like object mapping header names to values. + Returns all request headers as a dictionary-like object mapping header + names to values. + NOTE: If duplicate header names are permitted, then this interface will NOTE: need to change. """ @@ -68,9 +68,9 @@ def get_header_values(self, key): """ - A framework-specific method which returns a list of all request header - values associated with the given 'key'. Note that according to RFC 2616, - 'key' is treated as a case-insensitive string. + Returns a list of all request header values associated with the given + 'key'. Note that according to RFC 2616, 'key' is treated as a + case-insensitive string. """ return self.convert_to_list(self.trans.headers_in.get(key)) @@ -78,8 +78,8 @@ def get_content_type(self): """ - A framework-specific method which gets the content type specified on the - request, along with the charset employed. + Returns the content type specified on the request, along with the + charset employed. """ return self.parse_content_type(self.trans.content_type) @@ -95,8 +95,7 @@ def get_content_languages(self): """ - A framework-specific method which extracts language information from - the transaction. + Returns extracted language information from the transaction. """ return self.parse_content_preferences(self.trans.headers_in.get("Accept-Language")) @@ -104,7 +103,7 @@ def get_path(self): """ - A framework-specific method which gets the entire path from the request. + Returns the entire path from the request. """ query_string = self.get_query_string() @@ -116,8 +115,7 @@ def get_path_without_query(self): """ - A framework-specific method which gets the entire path from the request - minus the query string. + Returns the entire path from the request minus the query string. """ return self.trans.uri @@ -125,9 +123,8 @@ def get_path_info(self): """ - A framework-specific method which gets the "path info" (the part of the - URL after the resource name handling the current request) from the - request. + Returns the "path info" (the part of the URL after the resource name + handling the current request) from the request. """ return self.trans.path_info @@ -135,8 +132,7 @@ def get_query_string(self): """ - A framework-specific method which gets the query string from the path in - the request. + Returns the query string from the path in the request. """ return self.trans.args or "" @@ -146,9 +142,9 @@ def get_fields_from_path(self): """ - A framework-specific method which extracts the form fields from the - path specified in the transaction. The underlying framework may refuse - to supply fields from the path if handling a POST transaction. + Extracts the form fields from the path specified in the transaction. The + underlying framework may refuse to supply fields from the path if + handling a POST transaction. Returns a dictionary mapping field names to lists of values (even if a single value is associated with any given field name). @@ -159,11 +155,10 @@ def get_fields_from_body(self, encoding=None): """ - A framework-specific method which extracts the form fields from the - message body in the transaction. The optional 'encoding' parameter - specifies the character encoding of the message body for cases where no - such information is available, but where the default encoding is to be - overridden. + Extracts the form fields from the message body in the transaction. The + optional 'encoding' parameter specifies the character encoding of the + message body for cases where no such information is available, but where + the default encoding is to be overridden. Returns a dictionary mapping field names to lists of values (even if a single value is associated with any given field name). @@ -189,8 +184,7 @@ def get_user(self): """ - A framework-specific method which extracts user information from the - transaction. + Extracts user information from the transaction. Returns a username as a string or None if no user is defined. """ @@ -203,8 +197,7 @@ def get_cookies(self): """ - A framework-specific method which obtains cookie information from the - request. + Obtains cookie information from the request. Returns a dictionary mapping cookie names to cookie objects. @@ -220,8 +213,7 @@ def get_cookie(self, cookie_name): """ - A framework-specific method which obtains cookie information from the - request. + Obtains cookie information from the request. Returns a cookie object for the given 'cookie_name' or None if no such cookie exists. @@ -234,8 +226,7 @@ def get_response_stream(self): """ - A framework-specific method which returns the response stream for - the transaction. + Returns the response stream for the transaction. """ # Unicode can upset this operation. Using either the specified charset, @@ -275,8 +266,7 @@ def set_content_type(self, content_type): """ - A framework-specific method which sets the 'content_type' for the - response. + Sets the 'content_type' for the response. """ # Remember the content type for encoding purposes later. @@ -284,11 +274,12 @@ self.content_type = content_type self.trans.content_type = self.format_content_type(content_type) + # Higher level response-related methods. + def set_cookie(self, cookie): """ - A framework-specific method which stores the given 'cookie' object in - the response. + Stores the given 'cookie' object in the response. """ if Cookie: @@ -300,8 +291,7 @@ def set_cookie_value(self, name, value, path=None, expires=None): """ - A framework-specific method which stores a cookie with the given 'name' - and 'value' in the response. + Stores a cookie with the given 'name' and 'value' in the response. The optional 'path' is a string which specifies the scope of the cookie, and the optional 'expires' parameter is a value compatible with the @@ -324,9 +314,8 @@ def delete_cookie(self, cookie_name): """ - A framework-specific method which adds to the response a request that - the cookie with the given 'cookie_name' be deleted/discarded by the - client. + Adds to the response a request that the cookie with the given + 'cookie_name' be deleted/discarded by the client. """ # Create a special cookie, given that we do not know whether the browser @@ -348,8 +337,8 @@ def get_session(self, create=1): """ - A framework-specific method which returns a session corresponding to - an identifier supplied in the transaction. + Gets a session corresponding to an identifier supplied in the + transaction. If no session has yet been established according to information provided in the transaction then the optional 'create' parameter @@ -369,8 +358,8 @@ def expire_session(self): """ - A framework-specific method which expires any session established - according to information provided in the transaction. + Expires any session established according to information provided in the + transaction. """ session = self.get_session(create=0) diff -r d4a528c5688f -r bf79cd93cfcd WebStack/Twisted.py --- a/WebStack/Twisted.py Thu Aug 26 20:37:56 2004 +0000 +++ b/WebStack/Twisted.py Thu Aug 26 21:07:45 2004 +0000 @@ -29,8 +29,7 @@ def get_request_stream(self): """ - A framework-specific method which returns the request stream for - the transaction. + Returns the request stream for the transaction. """ return self.trans.content @@ -38,7 +37,7 @@ def get_request_method(self): """ - A framework-specific method which gets the request method. + Returns the request method. """ return self.trans.method @@ -46,8 +45,9 @@ def get_headers(self): """ - A framework-specific method which returns all request headers as a - dictionary-like object mapping header names to values. + Returns all request headers as a dictionary-like object mapping header + names to values. + NOTE: If duplicate header names are permitted, then this interface will NOTE: need to change. """ @@ -57,9 +57,9 @@ def get_header_values(self, key): """ - A framework-specific method which returns a list of all request header - values associated with the given 'key'. Note that according to RFC 2616, - 'key' is treated as a case-insensitive string. + Returns a list of all request header values associated with the given + 'key'. Note that according to RFC 2616, 'key' is treated as a + case-insensitive string. """ # Twisted does not convert the header key to lower case (which is the @@ -70,8 +70,8 @@ def get_content_type(self): """ - A framework-specific method which gets the content type specified on the - request, along with the charset employed. + Returns the content type specified on the request, along with the + charset employed. """ return self.parse_content_type(self.trans.getHeader("Content-Type")) @@ -87,8 +87,7 @@ def get_content_languages(self): """ - A framework-specific method which extracts language information from - the transaction. + Returns extracted language information from the transaction. """ return self.parse_content_preferences(self.trans.getHeader("Accept-Charset")) @@ -96,7 +95,7 @@ def get_path(self): """ - A framework-specific method which gets the entire path from the request. + Returns the entire path from the request. """ return self.trans.uri @@ -104,8 +103,7 @@ def get_path_without_query(self): """ - A framework-specific method which gets the entire path from the request - minus the query string. + Returns the entire path from the request minus the query string. """ return self.get_path().split("?")[0] @@ -113,9 +111,8 @@ def get_path_info(self): """ - A framework-specific method which gets the "path info" (the part of the - URL after the resource name handling the current request) from the - request. + Returns the "path info" (the part of the URL after the resource name + handling the current request) from the request. """ return "/%s" % "/".join(self.trans.postpath) @@ -123,8 +120,7 @@ def get_query_string(self): """ - A framework-specific method which gets the query string from the path in - the request. + Returns the query string from the path in the request. """ t = self.get_path().split("?") @@ -141,9 +137,9 @@ def get_fields_from_path(self): """ - A framework-specific method which extracts the form fields from the - path specified in the transaction. The underlying framework may refuse - to supply fields from the path if handling a POST transaction. + Extracts the form fields from the path specified in the transaction. The + underlying framework may refuse to supply fields from the path if + handling a POST transaction. Returns a dictionary mapping field names to lists of values (even if a single value is associated with any given field name). @@ -154,11 +150,10 @@ def get_fields_from_body(self, encoding=None): """ - A framework-specific method which extracts the form fields from the - message body in the transaction. The optional 'encoding' parameter - specifies the character encoding of the message body for cases where no - such information is available, but where the default encoding is to be - overridden. + Extracts the form fields from the message body in the transaction. The + optional 'encoding' parameter specifies the character encoding of the + message body for cases where no such information is available, but where + the default encoding is to be overridden. Returns a dictionary mapping field names to lists of values (even if a single value is associated with any given field name). @@ -175,8 +170,7 @@ def get_user(self): """ - A framework-specific method which extracts user information from the - transaction. + Extracts user information from the transaction. Returns a username as a string or None if no user is defined. """ @@ -195,8 +189,7 @@ def get_cookies(self): """ - A framework-specific method which obtains cookie information from the - request. + Obtains cookie information from the request. Returns a dictionary mapping cookie names to cookie objects. NOTE: Twisted does not seem to support this operation via methods. Thus, @@ -213,8 +206,7 @@ def get_cookie(self, cookie_name): """ - A framework-specific method which obtains cookie information from the - request. + Obtains cookie information from the request. Returns a cookie object for the given 'cookie_name' or None if no such cookie exists. @@ -229,8 +221,7 @@ def get_response_stream(self): """ - A framework-specific method which returns the response stream for - the transaction. + Returns the response stream for the transaction. """ # Unicode can upset this operation. Using either the specified charset, @@ -272,8 +263,7 @@ def set_content_type(self, content_type): """ - A framework-specific method which sets the 'content_type' for the - response. + Sets the 'content_type' for the response. """ # Remember the content type for encoding purposes later. @@ -286,8 +276,7 @@ def set_cookie(self, cookie): """ - A framework-specific method which stores the given 'cookie' object in - the response. + Stores the given 'cookie' object in the response. """ self.trans.addCookie(cookie.name, cookie.value, expires=cookie.expires, path=cookie.path) @@ -295,8 +284,7 @@ def set_cookie_value(self, name, value, path=None, expires=None): """ - A framework-specific method which stores a cookie with the given 'name' - and 'value' in the response. + Stores a cookie with the given 'name' and 'value' in the response. The optional 'path' is a string which specifies the scope of the cookie, and the optional 'expires' parameter is a value compatible with the @@ -309,9 +297,8 @@ def delete_cookie(self, cookie_name): """ - A framework-specific method which adds to the response a request that - the cookie with the given 'cookie_name' be deleted/discarded by the - client. + Adds to the response a request that the cookie with the given + 'cookie_name' be deleted/discarded by the client. """ # Create a special cookie, given that we do not know whether the browser diff -r d4a528c5688f -r bf79cd93cfcd WebStack/Webware.py --- a/WebStack/Webware.py Thu Aug 26 20:37:56 2004 +0000 +++ b/WebStack/Webware.py Thu Aug 26 21:07:45 2004 +0000 @@ -30,8 +30,7 @@ def get_request_stream(self): """ - A framework-specific method which returns the request stream for - the transaction. + Returns the request stream for the transaction. """ request = self.trans.request() @@ -51,7 +50,7 @@ def get_request_method(self): """ - A framework-specific method which gets the request method. + Returns the request method. """ return self.trans.request().method() @@ -59,8 +58,9 @@ def get_headers(self): """ - A framework-specific method which returns all request headers as a - dictionary-like object mapping header names to values. + Returns all request headers as a dictionary-like object mapping header + names to values. + NOTE: If duplicate header names are permitted, then this interface will NOTE: need to change. """ @@ -74,9 +74,9 @@ def get_header_values(self, key): """ - A framework-specific method which returns a list of all request header - values associated with the given 'key'. Note that according to RFC 2616, - 'key' is treated as a case-insensitive string. + Returns a list of all request header values associated with the given + 'key'. Note that according to RFC 2616, 'key' is treated as a + case-insensitive string. """ # Use the Webware environment and some assumptions about variable names. @@ -91,8 +91,8 @@ def get_content_type(self): """ - A framework-specific method which gets the content type specified on the - request, along with the charset employed. + Returns the content type specified on the request, along with the + charset employed. """ return self.parse_content_type(self.trans.request().contentType()) @@ -109,8 +109,7 @@ def get_content_languages(self): """ - A framework-specific method which extracts language information from - the transaction. + Returns extracted language information from the transaction. NOTE: Requires enhancements to HTTPRequest. """ @@ -119,7 +118,7 @@ def get_path(self): """ - A framework-specific method which gets the entire path from the request. + Returns the entire path from the request. """ return self.trans.request().uri() @@ -127,8 +126,7 @@ def get_path_without_query(self): """ - A framework-specific method which gets the entire path from the request - minus the query string. + Returns the entire path from the request minus the query string. """ return self.get_path().split("?")[0] @@ -136,9 +134,8 @@ def get_path_info(self): """ - A framework-specific method which gets the "path info" (the part of the - URL after the resource name handling the current request) from the - request. + Returns the "path info" (the part of the URL after the resource name + handling the current request) from the request. """ return self.trans.request().extraURLPath() @@ -146,8 +143,7 @@ def get_query_string(self): """ - A framework-specific method which gets the query string from the path in - the request. + Returns the query string from the path in the request. """ return self.trans.request().queryString() @@ -157,9 +153,9 @@ def get_fields_from_path(self): """ - A framework-specific method which extracts the form fields from the - path specified in the transaction. The underlying framework may refuse - to supply fields from the path if handling a POST transaction. + Extracts the form fields from the path specified in the transaction. The + underlying framework may refuse to supply fields from the path if + handling a POST transaction. Returns a dictionary mapping field names to lists of values (even if a single value is associated with any given field name). @@ -170,11 +166,10 @@ def get_fields_from_body(self, encoding=None): """ - A framework-specific method which extracts the form fields from the - message body in the transaction. The optional 'encoding' parameter - specifies the character encoding of the message body for cases where no - such information is available, but where the default encoding is to be - overridden. + Extracts the form fields from the message body in the transaction. The + optional 'encoding' parameter specifies the character encoding of the + message body for cases where no such information is available, but where + the default encoding is to be overridden. Returns a dictionary mapping field names to lists of values (even if a single value is associated with any given field name). @@ -197,8 +192,7 @@ def get_user(self): """ - A framework-specific method which extracts user information from the - transaction. + Extracts user information from the transaction. Returns a username as a string or None if no user is defined. """ @@ -218,8 +212,7 @@ def get_cookies(self): """ - A framework-specific method which obtains cookie information from the - request. + Obtains cookie information from the request. Returns a dictionary mapping cookie names to cookie objects. """ @@ -232,8 +225,7 @@ def get_cookie(self, cookie_name): """ - A framework-specific method which obtains cookie information from the - request. + Obtains cookie information from the request. Returns a cookie object for the given 'cookie_name' or None if no such cookie exists. @@ -249,8 +241,7 @@ def get_response_stream(self): """ - A framework-specific method which returns the response stream for - the transaction. + Returns the response stream for the transaction. """ # Unicode can upset this operation. Using either the specified charset, @@ -299,8 +290,7 @@ def set_content_type(self, content_type): """ - A framework-specific method which sets the 'content_type' for the - response. + Sets the 'content_type' for the response. """ # Remember the content type for encoding purposes later. @@ -313,8 +303,7 @@ def set_cookie(self, cookie): """ - A framework-specific method which stores the given 'cookie' object in - the response. + Stores the given 'cookie' object in the response. """ self.trans.response().addCookie(cookie) @@ -322,8 +311,7 @@ def set_cookie_value(self, name, value, path=None, expires=None): """ - A framework-specific method which stores a cookie with the given 'name' - and 'value' in the response. + Stores a cookie with the given 'name' and 'value' in the response. The optional 'path' is a string which specifies the scope of the cookie, and the optional 'expires' parameter is a value compatible with the @@ -335,9 +323,8 @@ def delete_cookie(self, cookie_name): """ - A framework-specific method which adds to the response a request that - the cookie with the given 'cookie_name' be deleted/discarded by the - client. + Adds to the response a request that the cookie with the given + 'cookie_name' be deleted/discarded by the client. """ self.trans.response().delCookie(cookie_name) @@ -347,8 +334,8 @@ def get_session(self, create=1): """ - A framework-specific method which returns a session corresponding to - an identifier supplied in the transaction. + Gets a session corresponding to an identifier supplied in the + transaction. If no session has yet been established according to information provided in the transaction then the optional 'create' parameter @@ -367,8 +354,8 @@ def expire_session(self): """ - A framework-specific method which expires any session established - according to information provided in the transaction. + Expires any session established according to information provided in the + transaction. """ self.trans.request().setSessionExpired(1)