diff options
Diffstat (limited to 'wsgitools/filters.py')
-rw-r--r-- | wsgitools/filters.py | 13 |
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)) |