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

Changeset 2059

Show
Ignore:
Timestamp:
10/30/08 18:35:26
Author:
lakin
Message:

#869 - added the ability for dynamic dispatching by the controller to better allow urls of the form: /users/123/addresses/3/city

Files:

Legend:

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

    r2030 r2059  
    228228        node = root 
    229229        names = [x for x in path.strip('/').split('/') if x] + ['index'] 
    230         for name in names: 
     230        iternames = names[:] 
     231        while iternames: 
     232            name = iternames[0] 
    231233            # map to legal Python identifiers (replace '.' with '_') 
    232234            objname = name.replace('.', '_') 
    233235             
    234236            nodeconf = {} 
    235             node = getattr(node, objname, None) 
     237            subnode = getattr(node, objname, None) 
     238            if subnode is None: 
     239                dispatch = getattr(node, 'dispatch', None) 
     240                if dispatch and callable(dispatch): 
     241                    subnode = dispatch(vpath=iternames) 
     242            name = iternames.pop(0) 
     243            node = subnode 
     244 
    236245            if node is not None: 
    237246                # Get _cp_config attached to this node. 
  • trunk/cherrypy/test/test.py

    r2018 r2059  
    383383        'test_logging', 
    384384        'test_objectmapping', 
     385        'test_dynamicobjectmapping', 
    385386        'test_misc_tools', 
    386387        'test_static', 

Hosted by WebFaction

Log in as guest/cpguest to create tickets