Download Install Tutorial Docs FAQ Tools WikiLicense Team IRC Planet Involvement Shop Book

Changeset 1387

Show
Ignore:
Timestamp:
09/29/06 19:26:55
Author:
fumanchu
Message:

New docstring for find_handler, plus tweaks.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/cherrypy/_cprequest.py

    r1386 r1387  
    149149     
    150150    def find_handler(self, path): 
    151         """Find the appropriate page handler for the given path.""" 
     151        """Return the appropriate page handler, plus any virtual path. 
     152         
     153        This will return two objects. The first will be a callable, 
     154        which can be used to generate page output. Any parameters from 
     155        the query string or request body will be sent to that callable 
     156        as keyword arguments. 
     157         
     158        The callable is found by traversing the application's tree, 
     159        starting from cherrypy.request.app.root, and matching path 
     160        components to successive objects in the tree. For example, the 
     161        URL "/path/to/handler" might return root.path.to.handler. 
     162         
     163        The second object returned will be a list of names which are 
     164        'virtual path' components: parts of the URL which are dynamic, 
     165        and were not used when looking up the handler. 
     166        These virtual path components are passed to the handler as 
     167        positional arguments. 
     168        """ 
    152169        request = cherrypy.request 
    153170        app = request.app 
     
    161178        if "/" in app.config: 
    162179            nodeconf.update(app.config["/"]) 
    163         object_trail = [('root', root, nodeconf, curpath)
     180        object_trail = [['root', root, nodeconf, curpath]
    164181         
    165182        node = root 
     
    181198                nodeconf.update(app.config[curpath]) 
    182199             
    183             object_trail.append((objname, node, nodeconf, curpath)
     200            object_trail.append([name, node, nodeconf, curpath]
    184201         
    185202        def set_conf(): 
     
    208225                    # Insert any extra _cp_config from the default handler. 
    209226                    conf = getattr(defhandler, "_cp_config", {}) 
    210                     object_trail.insert(i+1, ("default", defhandler, conf, curpath)
     227                    object_trail.insert(i+1, ["default", defhandler, conf, curpath]
    211228                    request.config = set_conf() 
    212229                    request.is_index = False 

Hosted by WebFaction

Log in as guest/cpguest to create tickets