summaryrefslogtreecommitdiff
path: root/wsgitools/filters.py
diff options
context:
space:
mode:
authorHelmut Grohne <helmut@subdivi.de>2007-04-15 18:14:57 +0200
committerHelmut Grohne <helmut@subdivi.de>2007-04-15 18:14:57 +0200
commit0b08dacfcfced7fef1b4818a73c3f43a97fe8c8f (patch)
tree1841f9a4c97faa3d5df147fdc6ebfe95e9b181e6 /wsgitools/filters.py
parentd6b64ecb5bfb6d49ca8e97f58e3ad65075810269 (diff)
downloadwsgitools-0b08dacfcfced7fef1b4818a73c3f43a97fe8c8f.tar.gz
added docstrings
Diffstat (limited to 'wsgitools/filters.py')
-rw-r--r--wsgitools/filters.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/wsgitools/filters.py b/wsgitools/filters.py
index 1d6154f..fa42550 100644
--- a/wsgitools/filters.py
+++ b/wsgitools/filters.py
@@ -148,6 +148,8 @@ class RequestLogWSGIFilter(BaseWSGIFilter):
"""This filter logs all requests in the apache log file format."""
@classmethod
def creator(cls, log):
+ """Returns a function creating RequestLogWSGIFilters on given log file.
+ log has to be a file-like object."""
return lambda:cls(log)
def __init__(self, log=sys.stdout):
self.log = log
@@ -189,8 +191,16 @@ class RequestLogWSGIFilter(BaseWSGIFilter):
__all__.append("TimerWSGIFilter")
class TimerWSGIFilter(BaseWSGIFilter):
+ """Replaces a specific string in the data returned from the filtered wsgi
+ application with the time the request took. The string has to be exactly
+ eight bytes long, defaults to "?GenTime" and must be an element of the
+ iterable returned by the filtered application. If the application returns
+ something like ["spam?GenTime", "?GenTime spam", "?GenTime"] only the last
+ occurance get's replaced."""
@classmethod
def creator(cls, pattern):
+ """Returns a function creating TimerWSGIFilters with a given pattern
+ beeing a string of exactly eight bytes."""
return lambda:cls(pattern)
def __init__(self, pattern="?GenTime"):
self.pattern = pattern
@@ -206,6 +216,8 @@ class EncodeWSGIFilter(BaseWSGIFilter):
"""Encodes all body data (no headers) with given charset."""
@classmethod
def creator(cls, charset):
+ """Returns a function creating EncodeWSGIFilters with a given charset.
+ """
return lambda:cls(charset)
def __init__(self, charset="utf-8"):
self.charset = charset
@@ -213,6 +225,7 @@ class EncodeWSGIFilter(BaseWSGIFilter):
"""BaseWSGIFilter interface"""
return data.encode(self.charset)
def filter_header(self, header, value):
+ """BaseWSGIFilter interface"""
if header.lower() != "content-type":
return (header, value)
return (header, "%s; charset=%s" % (value, self.charset))