From da7964ce7cbdc0e28c4558caabcf36d384253ed1 Mon Sep 17 00:00:00 2001 From: Helmut Grohne Date: Thu, 28 Feb 2008 14:03:55 +0100 Subject: refactored docstrings for epydoc --- wsgitools/adapters.py | 2 +- wsgitools/applications.py | 14 +++++++++----- wsgitools/digest.py | 28 +++++++++++++++------------- wsgitools/filters.py | 5 +++-- wsgitools/middlewares.py | 30 +++++++++++++++++------------- wsgitools/scgi/asynchronous.py | 17 ++++++++++------- wsgitools/scgi/forkpool.py | 26 +++++++++++++++++--------- 7 files changed, 72 insertions(+), 50 deletions(-) (limited to 'wsgitools') diff --git a/wsgitools/adapters.py b/wsgitools/adapters.py index f575295..37e16b8 100644 --- a/wsgitools/adapters.py +++ b/wsgitools/adapters.py @@ -25,7 +25,7 @@ class WSGI1to2Adapter: """Adapts a WSGI 1.0 application to something that might somewhen be the WSGI 2.0 interface.""" def __init__(self, app): - """app is a WSGI 1.0 application""" + """@param app: is a WSGI 1.0 application""" self.app = app def __call__(self, environ): """some interface that might somewhen be known as WSGI 2.0""" diff --git a/wsgitools/applications.py b/wsgitools/applications.py index dcbd78a..2e6703c 100644 --- a/wsgitools/applications.py +++ b/wsgitools/applications.py @@ -2,11 +2,15 @@ class StaticContent: """This wsgi application provides static content on whatever request it receives.""" def __init__(self, status, headers, content): - """status is the HTTP status returned to the browser (ex: "200 OK") - headers is a list of (header, value) pairs being delivered as HTTP - headers - content contains the data to be delivered to the client. It is either a - string or some kind of iterable yielding strings. + """ + @type status: str + @param status: is the HTTP status returned to the browser (ex: "200 OK") + @type headers: list + @param headers: is a list of (header, value) pairs being delivered as + HTTP headers + @type content: basestring + @param content: contains the data to be delivered to the client. It is + either a string or some kind of iterable yielding strings. """ assert isinstance(status, str) assert isinstance(headers, list) diff --git a/wsgitools/digest.py b/wsgitools/digest.py index a0eb973..7284c1c 100755 --- a/wsgitools/digest.py +++ b/wsgitools/digest.py @@ -38,14 +38,15 @@ class AuthTokenGenerator: interface consists of beeing callable with a username and having a realm attribute being a string.""" def __init__(self, realm, getpass): - """Realm is a string according to RFC2617. - The provided getpass function is called with a username and - password is expected as result. None may be used as an invalid - password.""" + """ + @param realm: is a string according to RFC2617. + @param getpass: this function is called with a username and password is + expected as result. None may be used as an invalid password.""" self.realm = realm self.getpass = getpass def __call__(self, username, algo="md5"): - """Generates an authentification token from a username.""" + """Generates an authentification token from a username. + @type username: str""" assert algo.lower() in ["md5", "md5-sess"] password = self.getpass(username) if password is None: @@ -58,15 +59,16 @@ class AuthDigestMiddleware: """Middleware partly implementing RFC2617. (md5-sess was omited)""" algorithms = {"md5": lambda data: md5.new(data).hexdigest()} def __init__(self, app, gentoken, maxage=300, maxuses=5): - """app is the wsgi application to be served with authentification. - gentoken has to have the same functionality and interface as the + """ + @param app: is the wsgi application to be served with authentification. + @param gentoken: has to have the same functionality and interface as the AuthTokenGenerator class. - maxage is the number of seconds a nonce may be valid. Choosing a large - value may result in more memory usage whereas a smaller value - results in more requests. Defaults to 5 minutes. - maxuses is the number of times a nonce may be used (with different nc - values). A value of 1 makes nonces usable exactly once - resulting in more requests. Defaults to 5. + @param maxage: is the number of seconds a nonce may be valid. Choosing a + large value may result in more memory usage whereas a smaller + value results in more requests. Defaults to 5 minutes. + @param maxuses: is the number of times a nonce may be used (with + different nc values). A value of 1 makes nonces usable exactly + once resulting in more requests. Defaults to 5. """ self.app = app self.gentoken = gentoken diff --git a/wsgitools/filters.py b/wsgitools/filters.py index 2233431..759b20c 100644 --- a/wsgitools/filters.py +++ b/wsgitools/filters.py @@ -112,8 +112,9 @@ class WSGIFilterMiddleware: """This wsgi middleware can be used with specialized BaseWSGIFilters to modify wsgi requests and/or reponses.""" def __init__(self, app, filterclass): - """app is a wsgi application. - filterclass is a subclass of BaseWSGIFilter or some class that + """ + @param app: is a wsgi application. + @param filterclass: is a subclass of BaseWSGIFilter or some class that implements the interface.""" self.app = app self.filterclass = filterclass diff --git a/wsgitools/middlewares.py b/wsgitools/middlewares.py index 4020f90..bee0ac3 100644 --- a/wsgitools/middlewares.py +++ b/wsgitools/middlewares.py @@ -93,14 +93,15 @@ class NoWriteCallableMiddleware: __all__.append("ContentLengthMiddleware") class ContentLengthMiddleware: """Guesses the content length header if possible. - Note: The application used must not use the write callable returned by - start_response.""" + @note: The application used must not use the write callable returned by + start_response.""" def __init__(self, app, maxstore=0): """Wraps wsgi application app. It can also store the first result bytes to possibly return a list of strings which will make guessing the size of iterators possible. At most maxstore bytes will be accumulated. Please note that a value larger than 0 will violate the wsgi standard. The magical value () will make it always gather all data. + @type maxstore: number """ self.app = app self.maxstore = maxstore @@ -181,12 +182,14 @@ class CachingMiddleware: """Caches reponses to requests based on SCRIPT_NAME, PATH_INFO and QUERY_STRING.""" def __init__(self, app, maxage=60, storable=storable, cacheable=cacheable): - """app is a wsgi application to be cached. - maxage is the number of seconds a reponse may be cached. - storable is a predicated that determines whether the response may be - cached at all based on the environ dict. - cacheable is a predicate that determines whether this request - invalidates the cache.""" + """ + @param app: is a wsgi application to be cached. + @type maxage: number + @param maxage: is the number of seconds a reponse may be cached. + @param storable: is a predicated that determines whether the response + may be cached at all based on the environ dict. + @param cacheable: is a predicate that determines whether this request + invalidates the cache.""" self.app = app self.maxage = maxage self.storable = storable @@ -238,7 +241,7 @@ __all__.append("DictAuthChecker") class DictAuthChecker: """Verifies usernames and passwords by looking them up in a dict.""" def __init__(self, users): - """users is a dict mapping usernames to password.""" + """@param users: is a dict mapping usernames to password.""" self.users = users def __call__(self, username, password): """check_function interface taking username and password and resulting @@ -249,10 +252,11 @@ __all__.append("BasicAuthMiddleware") class BasicAuthMiddleware: """Middleware implementing HTTP Basic Auth.""" def __init__(self, app, check_function, realm='www'): - """app is a WSGI application. - check_function is a function taking two arguments username and password - returning a bool indicating whether the request may is - allowed.""" + """ + @param app: is a WSGI application. + @param check_function: is a function taking two arguments username and + password returning a bool indicating whether the request may is + allowed.""" self.app = app self.check_function = check_function self.realm = realm diff --git a/wsgitools/scgi/asynchronous.py b/wsgitools/scgi/asynchronous.py index 4953b05..4b1ed8f 100644 --- a/wsgitools/scgi/asynchronous.py +++ b/wsgitools/scgi/asynchronous.py @@ -179,13 +179,16 @@ class SCGIServer(asyncore.dispatcher): """SCGI Server for WSGI applications. It does not use multiple processes or multiple threads.""" def __init__(self, wsgiapp, port, interface="localhost", error=sys.stderr): - """wsgiapp is the wsgi application to be run. - port is an int representing the TCP port number to be used. - interface is a string specifying the network interface to bind which - defaults to "localhost" making the server inaccessible over - network. - error is a file-like object being passed as wsgi.error in the environ - parameter defaulting to stderr.""" + """ + @param wsgiapp: is the wsgi application to be run. + @type port: number + @param port: is an int representing the TCP port number to be used. + @type interface: str + @param interface: is a string specifying the network interface to bind + which defaults to "localhost" making the server inaccessible + over network. + @param error: is a file-like object being passed as wsgi.error in the + environ parameter defaulting to stderr.""" asyncore.dispatcher.__init__(self) self.wsgiapp = wsgiapp self.error = error diff --git a/wsgitools/scgi/forkpool.py b/wsgitools/scgi/forkpool.py index bc1be08..44dd362 100644 --- a/wsgitools/scgi/forkpool.py +++ b/wsgitools/scgi/forkpool.py @@ -6,7 +6,7 @@ import sys class SocketFileWrapper: """Wraps a socket to a wsgi-compliant file-like object.""" def __init__(self, sock): - """@param sock is a socket.socket()""" + """@param sock: is a socket.socket()""" self.sock = sock self.buff = "" def read(self, size=None): @@ -77,14 +77,22 @@ class SCGIServer: def __init__(self, wsgiapp, port, interface="localhost", error=sys.stderr, minworkers=2, maxworkers=32, maxrequests=1000): - """Parameters: - wsgiapp is the WSGI application to be run. - port is the tcp port to listen on - interface is the interface to bind to (default: "localhost") - error is a filelike object beeing passed as wsgi.error in environ - minworkers is the number of worker processes to spawn - maxworkers is the maximum number of workers that can be spawned on demand - maxrequests is the number of requests a worker processes before dying + """ + @param wsgiapp: is the WSGI application to be run. + @type port: number + @param port: is the tcp port to listen on + @type interface: str + @param interface: is the interface to bind to (default: "localhost") + @param error: is a filelike object beeing passed as wsgi.error in + environ + @type minworkers: number + @param minworkers: is the number of worker processes to spawn + @type maxworkers: number + @param maxworkers: is the maximum number of workers that can be spawned + on demand + @type maxrequests: number + @param maxrequests: is the number of requests a worker processes before + dying """ assert hasattr(error, "write") self.wsgiapp = wsgiapp -- cgit v1.2.3