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

Changeset 275

Show
Ignore:
Timestamp:
06/10/05 22:54:24
Author:
mikerobi
Message:

new session filter (stay tuned for docs), new config.getAll function

Files:

Legend:

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

    r274 r275  
    2323    'session.cookieName': 'CherryPySession', 
    2424    'session.storageFileDir': '', 
     25     
     26    'sessionFilter.on': True, 
     27    'sessionFilter.timeout': 60, 
     28    'sessionFilter.cleanUpDelay': 60, 
     29    'sessionFilter.storageType' : 'ram', 
     30    'sessionFilter.cookieName': 'CherryPySession', 
     31    'sessionFilter.storageFileDir': '.sessionFiles', 
     32     
     33    'sessionFilter.new': 'sessionMap', # legacy setting 
    2534    } 
    2635configMap = {"/": defaultGlobal.copy()} 
     
    3948        _load(file) 
    4049 
    41 def get(key, defaultValue=None, returnSection=False): 
     50def get(key, defaultValue=None, returnSection=False, startPath = None): 
    4251    # Look, ma, no Python function calls! Uber-fast. 
     52    # start path lest you overload the starting search path (needed by getAll) 
     53     
    4354    global cpg 
    4455    if not cpg: 
    4556        import cpg 
    4657     
    47     try: 
    48         path = cpg.request.path 
    49     except AttributeError: 
    50         path = "/" 
     58    if startPath: 
     59        path = startPath 
     60    else: 
     61        try: 
     62            path = cpg.request.path 
     63        except AttributeError: 
     64            path = "/" 
    5165     
    5266    while True: 
     
    7185    else: 
    7286        return result 
     87         
     88import os.path 
     89 
     90def getAll(key): 
     91    """ 
     92    getAll will lookup the key in the current node and all of its parent nodes, 
     93    it will return a dictionary paths of each node containing the key and its value 
     94 
     95    This function is required by the session filter 
     96    """ 
     97    path = get(key, None, returnSection = True) 
     98    value = get(key) 
     99     
     100    result = {} 
     101    while value != None and path != '/': 
     102        result[path]= value 
     103        path = os.path.split(path)[0] 
     104        value = get(key, None, returnSection = False, startPath = path) 
     105        path  = get(key, None, returnSection = True, startPath = path) 
     106     
     107    if path == '/' and value != None: 
     108        result[path] = value 
     109     
     110    return result 
    73111 
    74112class CaseSensitiveConfigParser(ConfigParser.ConfigParser): 
  • trunk/cherrypy/_cpdefaults.py

    r267 r275  
    170170from cherrypy.lib.filter import baseurlfilter, cachefilter, \ 
    171171    decodingfilter, encodingfilter, gzipfilter, logdebuginfofilter, \ 
    172     sessionfilter, staticfilter, nsgmlsfilter, tidyfilter, \ 
     172    staticfilter, nsgmlsfilter, tidyfilter, \ 
    173173    virtualhostfilter, xmlrpcfilter 
     174 
     175from cherrypy.lib.filter.sessionfilter import sessionfilter 
    174176 
    175177_cachefilter = cachefilter.CacheFilter() 
  • trunk/cherrypy/_cphttptools.py

    r274 r275  
    390390        yield chunk 
    391391        chunk = input.read(chunkSize) 
     392    input.close() 
    392393 
    393394def flattener(input): 
  • trunk/cherrypy/_cpserver.py

    r267 r275  
    7575    cpg.request = local() 
    7676    cpg.response = local() 
     77 
     78    # Create as sessions object for accessing session data 
     79    cpg.sessions = local() 
    7780     
    7881    # Create threadData object as a thread-specific all-purpose storage 

Hosted by WebFaction

Log in as guest/cpguest to create tickets