Robert Brewer avatar Robert Brewer committed 10ed572

Some tool buglets and docs.

Comments (0)

Files changed (4)

cherrypy/_cptools.py

 Tools are usually designed to be used in a variety of ways (although some
 may only offer one if they choose):
     
-    Library calls: all tools are callables that can be used wherever needed.
+    Library calls:
+        All tools are callables that can be used wherever needed.
         The arguments are straightforward and should be detailed within the
         docstring.
     
         That is, "@tools.anytool()" should "turn on" the tool via the
         decorated function's _cp_config attribute.
     
-    CherryPy hooks: "hooks" are points in the CherryPy request-handling
-        process which may hand off control to registered callbacks. The
-        Request object possesses a "hooks" attribute (a HookMap) for
-        manipulating this. If a tool exposes a "_setup" callable, it
-        will be called once per Request (if the feature is "turned on"
-        via config).
+    CherryPy config:
+        Hookpoints are places in the CherryPy request-handling process
+        which may hand off control to registered callbacks. The Request
+        object possesses a "hooks" attribute (a HookMap) for manipulating
+        this. If a tool exposes a "_setup" callable, it will be called
+        once per Request (if the feature is "turned on" via config).
 
 Tools may be implemented as any object with a namespace. The builtins
 are generally either modules or instances of the tools.Tool class.
     def _setup(self):
         """Hook this tool into cherrypy.request."""
         request = cherrypy.request
+        
         # Guard against running this method twice.
         if hasattr(request, 'xmlrpc'):
             return
         request.xmlrpc = True
+        
         request.error_response = _xmlrpc.on_error
         path_info = request.path_info
         ppath = _xmlrpc.patched_path(path_info)
 
 
 default_toolbox = _d = Toolbox("tools")
-default_toolbox.session_auth = SessionAuthTool(cptools.session_auth)
+_d.session_auth = SessionAuthTool(cptools.session_auth)
 _d.proxy = Tool('before_request_body', cptools.proxy, priority=30)
 _d.response_headers = Tool('on_start_resource', cptools.response_headers)
 _d.virtual_host = Tool('on_start_resource', cptools.virtual_host, priority=40)

cherrypy/lib/cptools.py

     for k, v in kwargs.iteritems():
         setattr(sa, k, v)
     return sa.run()
+session_auth.__doc__ = """Session authentication hook.
+
+Any attribute of the SessionAuth class may be overridden via a keyword arg
+to this function:
+
+""" + "\n".join(["%s: %s" % (k, type(getattr(SessionAuth, k)).__name__)
+                 for k in dir(SessionAuth) if not k.startswith("__")])
 
 
 def virtual_host(use_x_forwarded_host=True, **domains):

cherrypy/lib/encoding.py

         elif isinstance(value, list):
             # value is a list: decode each element
             decoded_params[key] = [v.decode(encoding) for v in value]
+        elif isinstance(value, unicode):
+            pass
         else:
             # value is a regular string: decode it
             decoded_params[key] = value.decode(encoding)

cherrypy/lib/wsgiapp.py

 
 
 def run(app, env=None):
-    """Run the (WSGI) app and set response.body to its output"""
+    """Run the given WSGI app and set response.body to its output."""
     try:
-        environ = cherrypy.request.wsgi_environ
+        environ = cherrypy.request.wsgi_environ.copy()
         environ['SCRIPT_NAME'] = cherrypy.request.script_name
         environ['PATH_INFO'] = cherrypy.request.path_info
     except AttributeError:
     # run the wsgi app and have it set response.body
     response = app(environ, start_response)
     try:
-        cherrypy.response.body = response
+        cherrypy.response.body = [x for x in response]
     finally:
         if hasattr(response, "close"):
             response.close()
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.