Changeset 1605
- Timestamp:
- 01/26/07 21:54:19
- Files:
-
- trunk/cherrypy/_cpconfig.py (modified) (3 diffs)
- trunk/cherrypy/_cpdispatch.py (modified) (1 diff)
- trunk/cherrypy/_cptree.py (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/cherrypy/_cpconfig.py
r1590 r1605 52 52 index.exposed = True 53 53 index._cp_config = {'request.show_tracebacks': False} 54 55 Note, however, that this behavior is only guaranteed for the default 56 dispatcher. Other dispatchers may have different restrictions on where 57 you can attach _cp_config attributes. 54 58 55 59 … … 70 74 These can only be declared in the global config. 71 75 tools: Runs and configures additional request-processing packages. 76 wsgi: Adds WSGI middleware to an Application's "pipeline". 77 These can only be declared in the app's root config ("/"). 72 78 checker: Controls the 'checker', which looks for common errors in 73 79 app state (including config) when the engine starts. … … 82 88 or Request level, by adding a named handler to cherrypy.config.namespaces, 83 89 app.namespaces, or cherrypy.engine.request_class.namespaces. The name can 84 be any string, and the handler must be either a callable or a context85 manager.90 be any string, and the handler must be either a callable or a (Python 2.5 91 style) context manager. 86 92 """ 87 93 trunk/cherrypy/_cpdispatch.py
r1604 r1605 49 49 50 50 class Dispatcher(object): 51 """CherryPy Dispatcher which walks a tree of objects to find a handler. 52 53 The tree is rooted at cherrypy.request.app.root, and each hierarchical 54 component in the path_info argument is matched to a corresponding nested 55 attribute of the root object. Matching handlers must have an 'exposed' 56 attribute which evaluates to True. The special method name "index" 57 matches a URI which ends in a slash ("/"). The special method name 58 "default" may match a portion of the path_info (but only when no longer 59 substring of the path_info matches some other object). 60 61 This is the default, built-in dispatcher for CherryPy. 62 """ 51 63 52 64 def __call__(self, path_info): trunk/cherrypy/_cptree.py
r1458 r1605 11 11 An instance of this class may also be used as a WSGI callable 12 12 (WSGI application object) for itself. 13 """ 13 14 14 root: the top-most container of page handlers for this app. 15 script_name: the URL "mount point" for this app; for example, 16 if script_name is "/my/cool/app", then the URL 17 "http://my.domain.tld/my/cool/app/page1" might be handled 18 by a "page1" method on the root object. If script_name is 19 explicitly set to None, then CherryPy will attempt to provide 20 it each time from request.wsgi_environ['SCRIPT_NAME']. 21 config: a dict of {path: pathconf} pairs, where 'pathconf' is itself 22 a dict of {key: value} pairs. 15 __metaclass__ = cherrypy._AttributeDocstrings 16 17 root = None 18 root__doc = """ 19 The top-most container of page handlers for this app. Handlers should 20 be arranged in a hierarchy of attributes, matching the expected URI 21 hierarchy; the default dispatcher then searches this hierarchy for a 22 matching handler. When using a dispatcher other than the default, 23 this value may be None.""" 24 25 config = {} 26 config__doc = """ 27 A dict of {path: pathconf} pairs, where 'pathconf' is itself a dict 28 of {key: value} pairs.""" 29 30 namespaces = {} 31 namespaces__doc = """ 32 A dict of config namespace names and handlers. Each config entry should 33 begin with a namespace name; the corresponding namespace handler will 34 be called once for each config entry in that namespace, and will be 35 passed two arguments: the config key (with the namespace removed) 36 and the config value. 37 38 Namespace handlers may be any Python callable; they may also be 39 Python 2.5-style 'context managers', in which case their __enter__ 40 method should return a callable to be used as the handler. 41 See cherrypy.tools (the Toolbox class) for an example. 23 42 """ 43 44 log = None 45 log__doc = """A LogManager instance. See _cplogging.""" 46 47 wsgiapp = None 48 wsgiapp__doc = """A CPWSGIApp instance. See _cpwsgi.""" 24 49 25 50 def __init__(self, root, script_name=""): … … 28 53 self.script_name = script_name 29 54 self.wsgiapp = _cpwsgi.CPWSGIApp(self) 30 self.namespaces = {"log": lambda k, v: setattr(self.log, k, v), 31 "wsgi": self.wsgiapp.namespace_handler, 32 } 55 56 self.namespaces = self.namespaces.copy() 57 self.namespaces["log"] = lambda k, v: setattr(self.log, k, v) 58 self.namespaces["wsgi"] = self.wsgiapp.namespace_handler 59 33 60 self.config = {} 34 61 62 script_name__doc = """ 63 The URI "mount point" for this app; for example, if script_name is 64 "/my/cool/app", then the URL "http://my.domain.tld/my/cool/app/page1" 65 might be handled by a "page1" method on the root object. If script_name 66 is explicitly set to None, then the script_name will be provided 67 for each call from request.wsgi_environ['SCRIPT_NAME'].""" 35 68 def _get_script_name(self): 36 69 if self._script_name is None: … … 40 73 def _set_script_name(self, value): 41 74 self._script_name = value 42 script_name = property(fget=_get_script_name, fset=_set_script_name) 75 script_name = property(fget=_get_script_name, fset=_set_script_name, 76 doc=script_name__doc) 43 77 44 78 def merge(self, config): … … 59 93 (WSGI application object), in which case it dispatches to all 60 94 mounted apps. 95 """ 61 96 62 apps: a dict of the form {script name: application}, where "script name" 63 is a string declaring the URL mount point (no trailing slash), 64 and "application" is an instance of cherrypy.Application (or an 65 arbitrary WSGI callable if you happen to be using a WSGI server). 66 """ 97 apps = {} 98 apps__doc = """ 99 A dict of the form {script name: application}, where "script name" 100 is a string declaring the URI mount point (no trailing slash), and 101 "application" is an instance of cherrypy.Application (or an arbitrary 102 WSGI callable if you happen to be using a WSGI server).""" 67 103 68 104 def __init__(self):

