summaryrefslogtreecommitdiff
path: root/wsgitools/middlewares.py
diff options
context:
space:
mode:
authorHelmut Grohne <helmut@subdivi.de>2008-03-27 14:40:50 +0100
committerHelmut Grohne <helmut@subdivi.de>2008-03-27 14:40:50 +0100
commit5ddc8460de1d3bf1ea41eb4fdc7079d15dcf6837 (patch)
treeca9f7a53eda8596b9f9d83e836ec110a10af2467 /wsgitools/middlewares.py
parentc44530be1a4028ecf62b13dc24b847442114b2ec (diff)
downloadwsgitools-5ddc8460de1d3bf1ea41eb4fdc7079d15dcf6837.tar.gz
epydoc update
Diffstat (limited to 'wsgitools/middlewares.py')
-rw-r--r--wsgitools/middlewares.py44
1 files changed, 35 insertions, 9 deletions
diff --git a/wsgitools/middlewares.py b/wsgitools/middlewares.py
index bee0ac3..871105c 100644
--- a/wsgitools/middlewares.py
+++ b/wsgitools/middlewares.py
@@ -13,10 +13,17 @@ __all__.append("SubdirMiddleware")
class SubdirMiddleware:
"""Middleware choosing wsgi applications based on a dict."""
def __init__(self, default, mapping={}):
+ """
+ @type default: wsgi app
+ @type mapping: {str: wsgi app}
+ """
self.default = default
self.mapping = mapping
def __call__(self, environ, start_response):
- """wsgi interface"""
+ """wsgi interface
+ @type environ: {str: str}
+ @rtype: gen([str])
+ """
assert isinstance(environ, dict)
app = None
script = environ["PATH_INFO"]
@@ -45,7 +52,10 @@ class NoWriteCallableMiddleware:
"""Wraps wsgi application app."""
self.app = app
def __call__(self, environ, start_response):
- """wsgi interface"""
+ """wsgi interface
+ @type environ: {str, str}
+ @rtype: gen([str])
+ """
assert isinstance(environ, dict)
todo = []
def modified_start_response(status, headers, exc_info=None):
@@ -196,7 +206,9 @@ class CachingMiddleware:
self.cacheable = cacheable
self.cache = {}
def __call__(self, environ, start_response):
- """wsgi interface"""
+ """wsgi interface
+ @type environ: {str: str}
+ """
assert isinstance(environ, dict)
if not self.storable(environ):
return self.app(environ, start_response)
@@ -241,11 +253,17 @@ __all__.append("DictAuthChecker")
class DictAuthChecker:
"""Verifies usernames and passwords by looking them up in a dict."""
def __init__(self, users):
- """@param users: is a dict mapping usernames to password."""
+ """
+ @type users: {str: str}
+ @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
- in a bool."""
+ in a bool.
+ @type username: str
+ @type password: str
+ @rtype: bool
+ """
return username in self.users and self.users[username] == password
__all__.append("BasicAuthMiddleware")
@@ -256,13 +274,17 @@ class BasicAuthMiddleware:
@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."""
+ allowed.
+ @type realm: str
+ """
self.app = app
self.check_function = check_function
self.realm = realm
def __call__(self, environ, start_response):
- """wsgi interface"""
+ """wsgi interface
+ @type environ: {str: str}
+ """
assert isinstance(environ, dict)
auth = environ.get("HTTP_AUTHORIZATION")
if not auth or ' ' not in auth:
@@ -281,7 +303,9 @@ class BasicAuthMiddleware:
return self.authorization_required(environ, start_response)
def authorization_required(self, environ, start_response):
- """wsgi application for indicating authorization is required."""
+ """wsgi application for indicating authorization is required.
+ @type environ: {str: str}
+ """
status = "401 Authorization required"
html = "<html><head><title>Authorization required</title></head>" + \
"<body><h1>Authorization required</h1></body></html>\n"
@@ -301,7 +325,9 @@ class TracebackMiddleware:
"""app is the wsgi application to proxy."""
self.app = app
def __call__(self, environ, start_response):
- """wsgi interface"""
+ """wsgi interface
+ @type environ: {str: str}
+ """
try:
assert isinstance(environ, dict)
ret = self.app(environ, start_response)