Changeset 814
- Timestamp:
- 11/12/05 01:20:12
- Files:
-
- trunk/cherrypy/filters/__init__.py (modified) (4 diffs)
- trunk/cherrypy/filters/baseurlfilter.py (modified) (2 diffs)
- trunk/cherrypy/filters/cachefilter.py (modified) (2 diffs)
- trunk/cherrypy/filters/decodingfilter.py (modified) (2 diffs)
- trunk/cherrypy/filters/encodingfilter.py (modified) (2 diffs)
- trunk/cherrypy/filters/gzipfilter.py (modified) (2 diffs)
- trunk/cherrypy/filters/logdebuginfofilter.py (modified) (3 diffs)
- trunk/cherrypy/filters/nsgmlsfilter.py (modified) (3 diffs)
- trunk/cherrypy/filters/sessionauthenticatefilter.py (modified) (2 diffs)
- trunk/cherrypy/filters/sessionfilter.py (modified) (2 diffs)
- trunk/cherrypy/filters/staticfilter.py (modified) (2 diffs)
- trunk/cherrypy/filters/tidyfilter.py (modified) (2 diffs)
- trunk/cherrypy/filters/xmlrpcfilter.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/cherrypy/filters/__init__.py
r808 r814 2 2 from cherrypy import _cputil 3 3 4 # Filters that are always included5 from cherrypy.filters import baseurlfilter, cachefilter, \6 decodingfilter, encodingfilter, gzipfilter, logdebuginfofilter, \7 staticfilter, nsgmlsfilter, tidyfilter, \8 xmlrpcfilter, sessionauthenticatefilter, \9 sessionfilter10 11 # this contains the classes for each filter type12 # we do not store the instances here because the test13 # suite must reinitialize the filters without restarting14 # the server15 _classes = {16 'BaseUrlFilter' : baseurlfilter.BaseUrlFilter,17 'CacheFilter' : cachefilter.CacheFilter,18 'DecodingFilter' : decodingfilter.DecodingFilter,19 'EncodingFilter' : encodingfilter.EncodingFilter,20 'GzipFilter' : gzipfilter.GzipFilter,21 'LogDebugInfoFilter' : logdebuginfofilter.LogDebugInfoFilter,22 'NsgmlsFilter' : nsgmlsfilter.NsgmlsFilter,23 'SessionAuthenticateFilter' : sessionauthenticatefilter.SessionAuthenticateFilter,24 'SessionFilter' : sessionfilter.SessionFilter,25 'StaticFilter' : staticfilter.StaticFilter,26 'TidyFilter' : tidyfilter.TidyFilter,27 'XmlRpcFilter' : xmlrpcfilter.XmlRpcFilter,28 }29 30 4 # These are in order for a reason! 31 # They must be strings matching keys in _classes5 # They must be strings matching keys in classMap 32 6 _input_order = [ 33 7 'CacheFilter', … … 61 35 def init(): 62 36 """Initialize the filters.""" 37 38 from cherrypy.filters import baseurlfilter, cachefilter, \ 39 decodingfilter, encodingfilter, gzipfilter, logdebuginfofilter, \ 40 staticfilter, nsgmlsfilter, tidyfilter, \ 41 xmlrpcfilter, sessionauthenticatefilter, \ 42 sessionfilter 43 44 classMap = { 45 'BaseUrlFilter' : baseurlfilter.BaseUrlFilter, 46 'CacheFilter' : cachefilter.CacheFilter, 47 'DecodingFilter' : decodingfilter.DecodingFilter, 48 'EncodingFilter' : encodingfilter.EncodingFilter, 49 'GzipFilter' : gzipfilter.GzipFilter, 50 'LogDebugInfoFilter' : logdebuginfofilter.LogDebugInfoFilter, 51 'NsgmlsFilter' : nsgmlsfilter.NsgmlsFilter, 52 'SessionAuthenticateFilter' : sessionauthenticatefilter.SessionAuthenticateFilter, 53 'SessionFilter' : sessionfilter.SessionFilter, 54 'StaticFilter' : staticfilter.StaticFilter, 55 'TidyFilter' : tidyfilter.TidyFilter, 56 'XmlRpcFilter' : xmlrpcfilter.XmlRpcFilter, 57 } 58 63 59 instances = {} 64 60 inputs, outputs = [], [] … … 69 65 f = instances.get(name) 70 66 if f is None: 71 f = instances[name] = _classes[name]()67 f = instances[name] = classMap[name]() 72 68 inputs.append(f) 73 69 … … 75 71 f = instances.get(name) 76 72 if f is None: 77 f = instances[name] = _classes[name]()73 f = instances[name] = classMap[name]() 78 74 outputs.append(f) 79 75 trunk/cherrypy/filters/baseurlfilter.py
r808 r814 1 1 import cherrypy 2 2 from basefilter import BaseFilter 3 3 … … 10 10 11 11 def beforeRequestBody(self): 12 import cherrypy13 14 12 if not cherrypy.config.get('baseUrlFilter.on', False): 15 13 return trunk/cherrypy/filters/cachefilter.py
r808 r814 4 4 import time 5 5 6 import cherrypy 6 7 import basefilter 7 8 … … 94 95 maxobjects = property(lambda self: cherrypy.config.get("cacheFilter.maxobjects", 1000)) 95 96 96 def onStartResource(self):97 # We have to dynamically import cherrypy because Python can't handle98 # circular module imports :-(99 global cherrypy100 import cherrypy101 cherrypy.request.cacheable = True102 103 97 def beforeMain(self): 104 98 if not cherrypy.config.get('cacheFilter.on', False): trunk/cherrypy/filters/decodingfilter.py
r808 r814 1 1 import cherrypy 2 2 from basefilter import BaseFilter 3 3 … … 6 6 7 7 def beforeMain(self): 8 # We have to dynamically import cherrypy because Python can't handle9 # circular module imports :-(10 global cherrypy11 import cherrypy12 13 8 if not cherrypy.config.get('decodingFilter.on', False): 14 9 return trunk/cherrypy/filters/encodingfilter.py
r808 r814 1 1 import cherrypy 2 2 from basefilter import BaseFilter 3 3 … … 6 6 7 7 def beforeFinalize(self): 8 # We have to dynamically import cherrypy because Python can't handle9 # circular module imports :-(10 global cherrypy11 import cherrypy12 13 8 conf = cherrypy.config.get 14 9 if not conf('encodingFilter.on', False): trunk/cherrypy/filters/gzipfilter.py
r808 r814 1 2 import zlib3 1 import struct 4 2 import time 3 import zlib 4 5 import cherrypy 5 6 from basefilter import BaseFilter 6 7 … … 9 10 10 11 def beforeFinalize(self): 11 # We have to dynamically import cherrypy because Python can't handle12 # circular module imports :-(13 global cherrypy14 import cherrypy15 16 12 if not cherrypy.config.get('gzipFilter.on', False): 17 13 return trunk/cherrypy/filters/logdebuginfofilter.py
r808 r814 1 2 1 import time 3 2 … … 7 6 import pickle 8 7 8 import cherrypy 9 9 from basefilter import BaseFilter 10 10 … … 14 14 15 15 def onStartResource(self): 16 # We have to dynamically import cherrypy because Python can't handle17 # circular module imports :-(18 global cherrypy19 import cherrypy20 16 cherrypy.request.startBuilTime = time.time() 21 17 trunk/cherrypy/filters/nsgmlsfilter.py
r808 r814 1 import os, cgi 1 2 2 import os, cgi3 import cherrypy 3 4 from basefilter import BaseFilter 4 5 … … 9 10 10 11 def beforeFinalize(self): 11 # We have to dynamically import cherrypy because Python can't handle12 # circular module imports :-(13 global cherrypy14 import cherrypy15 16 12 if not cherrypy.config.get('nsgmlsFilter.on', False): 17 13 return … … 65 61 cherrypy.response.body = [newBody] 66 62 67 trunk/cherrypy/filters/sessionauthenticatefilter.py
r808 r814 1 1 import cherrypy 2 2 from basefilter import BaseFilter 3 3 … … 25 25 Filter allows for simple forms based authentication and access control 26 26 """ 27 27 28 28 def beforeMain(self): 29 import cherrypy30 29 if not cherrypy.config.get('sessionAuthenticateFilter.on', False): 31 30 return trunk/cherrypy/filters/sessionfilter.py
r808 r814 34 34 import types 35 35 36 import cherrypy 36 37 import basefilter 37 38 … … 55 56 56 57 def beforeRequestBody(self): 57 # We have to dynamically import cherrypy because Python can't handle58 # circular module imports :-(59 global cherrypy60 import cherrypy61 58 conf = cherrypy.config.get 62 59 trunk/cherrypy/filters/staticfilter.py
r808 r814 1 1 import os 2 2 import urllib 3 from basefilter import BaseFilter 3 4 import cherrypy 5 from cherrypy.lib import cptools 6 from cherrypy.filters.basefilter import BaseFilter 4 7 5 8 … … 8 11 9 12 def beforeMain(self): 10 from cherrypy import config, request 11 from cherrypy.lib import cptools 12 13 config = cherrypy.config 13 14 if not config.get('staticFilter.on', False): 14 15 return 15 16 17 request = cherrypy.request 16 18 path = request.objectPath 17 19 trunk/cherrypy/filters/tidyfilter.py
r808 r814 1 import os, cgi, StringIO, traceback 1 import cgi 2 import os 3 import StringIO 4 import traceback 5 6 import cherrypy 2 7 from basefilter import BaseFilter 3 8 … … 13 18 14 19 def beforeFinalize(self): 15 import cherrypy16 17 20 if not cherrypy.config.get('tidyFilter.on', False): 18 21 return trunk/cherrypy/filters/xmlrpcfilter.py
r808 r814 80 80 ###################################################################### 81 81 82 import xmlrpclib 83 84 import cherrypy 82 85 from basefilter import BaseFilter 83 import xmlrpclib84 86 85 87 … … 118 120 return result 119 121 120 def onStartResource(self):121 # We have to dynamically import cherrypy because Python can't handle122 # circular module imports :-(123 global cherrypy124 import cherrypy125 126 122 def beforeRequestBody(self): 127 123 """ Called after the request header has been read/parsed"""

