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

Changeset 1282

Show
Ignore:
Timestamp:
08/26/06 13:20:29
Author:
fumanchu
Message:

Fix to config.getAll (which isn't used internally and will disappear in future versions ;).

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/cherrypy-2.x/cherrypy/config.py

    r1004 r1282  
    185185 
    186186def getAll(key): 
    187     """Lookup key in the current node and all of its parent nodes 
    188     as a list of path, value pairs. 
    189     """ 
    190     # Needed by the session filter 
    191      
     187    """Return a list of (path, value) pairs for current node and all parents.""" 
    192188    try: 
    193189        results = [('global', configs['global'][key])] 
     
    200196        return results 
    201197     
    202     pathList = path.split('/') 
    203      
    204     for n in xrange(1, len(pathList)): 
    205         path = '/' + '/'.join(pathList[0:n+1]) 
     198    try: 
     199        results.append(('/', configs['/'][key])) 
     200    except KeyError: 
     201        pass 
     202     
     203    atoms = path.strip('/').split('/') 
     204    path = "" 
     205    for atom in atoms: 
     206        path = path + "/" + atom 
    206207        try: 
    207208            results.append((path, configs[path][key])) 
  • branches/cherrypy-2.x/cherrypy/test/test_config.py

    r1022 r1282  
    2222        bar = index 
    2323        nex = index 
     24         
     25        def getall(self, key): 
     26            return repr(cherrypy.config.getAll(key)) 
     27        getall.exposed = True 
    2428     
    2529    class Env: 
     
    9195            self.getPage(path + "?key=" + key) 
    9296            self.assertBody(expected) 
     97         
     98        self.getPage("/foo/getall?key=foo") 
     99        self.assertBody("[('/', 'this'), ('/foo', 'this2')]") 
    93100     
    94101    def testUnrepr(self): 

Hosted by WebFaction

Log in as guest/cpguest to create tickets