Changeset 541
- Timestamp:
- 08/18/05 10:59:17
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/cherrypy/lib/filter/sessionfilter/__init__.py
r540 r541 61 61 cherrypy.config.update(_sessionDefaults, override = False) 62 62 self.sessionManager = self.__newSessionManager(sessionName, sessionPath) 63 self.sessionManager.settings = local()64 63 65 64 def __newSessionManager(self, sessionName, sessionPath): … … 92 91 93 92 94 def __loadConfigData(self, sessionManager):95 settings = {}96 for settingName in _sessionSettingNames:97 default = cherrypy.config.get('sessionFilter.%s' % settingName)98 value = cherrypy.config.get('sessionFilter.%s.%s' % (sessionManager.name, settingName), default)99 settings[settingName] = value100 101 setattr(sessionManager.settings, settingName, value)102 103 93 def __loadSessions(self): 104 # look up all of the session keys by cookie94 105 95 sessionManager = self.sessionManager 106 96 sessionName = sessionManager.name … … 109 99 return 110 100 111 self.__loadConfigData(sessionManager)112 113 101 cookieName = sessionManager.cookieName 114 102 … … 117 105 except KeyError: 118 106 sessionKey = sessionManager.createSession() 119 self.saveSessionDictKey(sessionKey , sessionManager)107 self.saveSessionDictKey(sessionKey) 120 108 sessionManager.loadSession(sessionKey) 121 109 … … 124 112 except SessionNotFoundError: 125 113 sessionKey = sessionManager.createSession() 126 self.saveSessionDictKey(sessionKey , sessionManager)114 self.saveSessionDictKey(sessionKey) 127 115 sessionManager.loadSession(sessionKey) 128 116 129 def saveSessionDictKey(self, sessionKey , sessionManager):117 def saveSessionDictKey(self, sessionKey): 130 118 """ 131 119 Sets the session key in a cookie. 132 120 """ 121 122 sessionManager = self.sessionManager 133 123 134 124 sessionName = sessionManager.name … … 138 128 # if we do not have a manually defined cookie path use path where the session 139 129 # manager was defined 140 try:141 cookiePath = self.settings.cookiePath142 except AttributeError:130 131 cookiePath = sessionManager.getSetting('cookiePath') 132 if not cookiePath: 143 133 cookiePath = sessionManager.path 144 134 145 timeout = sessionManager. settings.timeout135 timeout = sessionManager.getSetting('timeout') 146 136 147 137 cherrypy.response.simpleCookie[cookieName] = sessionKey … … 150 140 151 141 # try and set the cookie domain 152 try:153 cookieDomain = self.settings.cookieDomain142 cookieDomain = sessionManager.getSetting('cookieDomain') 143 if cookieDomain: 154 144 cherrypy.response.simpleCookie[cookieName]['domain'] = cookieDomain 155 except AttributeError:156 pass157 145 158 146 # try and set a cookie comment 159 try:160 cookieComment = self.settings.cookieComment147 cookieComment = sessionManager.getSetting('cookieComment') 148 if cookieComment: 161 149 cherrypy.response.simpleCookie[cookieName]['comment'] = cookieComment 162 except AttributeError:163 pass164 150 165 151 def __saveSessions(self): trunk/cherrypy/lib/filter/sessionfilter/baseadaptor.py
r540 r541 65 65 """ Function to return a new sessioId """ 66 66 try: 67 sessionKeyFunc = self. settings.keyGenerator67 sessionKeyFunc = self.getSetting('keyGenerator') 68 68 except AttributeError: 69 69 sessionKeyFunc = None … … 104 104 from cherrypy._cpthreadinglocal import local 105 105 106 # settings dict107 self.settings = local()108 109 110 106 # there should never be a reason to modify the remaining functions, they used 111 107 # internally by the sessionFilter … … 114 110 return { 115 111 'timestamp' : int(time.time()), 116 'timeout' : self. settings.timeout,112 'timeout' : self.getSetting('timeout'), 117 113 'lastAccess' : int(time.time()), 118 114 'key' : self.generateSessionKey() … … 120 116 121 117 def getSetting(self, settingName, default = None): 122 try:123 return getattr(self.settings, settingName)124 except AttributeError:125 118 missing = object() 126 119 result = cherrypy.config.get('sessionFilter.%s.%s' % (self.name, settingName), missing) … … 167 160 self.saveSessionDict(session) 168 161 169 cacheTimeout = self. settings.cacheTimeout162 cacheTimeout = self.getSetting('cacheTimeout') 170 163 171 164 if session.threadCount == 0 and (self.noCache or not cacheTimeout): … … 180 173 """ cleanup all inactive sessions """ 181 174 182 cacheTimeout = self. settings.cacheTimeout175 cacheTimeout = self.getSetting('cacheTimeout') 183 176 184 177 # don't waste cycles if we aren't caching inactive sessions trunk/cherrypy/lib/filter/sessionfilter/fileadaptor.py
r540 r541 56 56 raise SessionNotFoundError 57 57 58 storagePath = self. settings.storagePath58 storagePath = self.getSetting('storagePath') 59 59 60 60 fileName = '%s-%s' % (self.name, sessionKey) … … 75 75 def saveSessionDict(self, sessionData): 76 76 77 storagePath = self. settings.storagePath77 storagePath = self.getSetting('storagePath') 78 78 79 79 fileName = '%s-%s' % (self.name, sessionData.key) … … 87 87 88 88 def deleteSession(self, sessionKey): 89 storagePath = self. settings.storagePath89 storagePath = self.getSetting('storagePath') 90 90 fileName = '%s-%s' % (self.name, sessionKey) 91 91 filePath = os.path.join(storagePath, fileName) … … 97 97 98 98 def _cleanUpOldSessions(self): 99 storagePath = self. settings.storagePath99 storagePath = self.getSetting('storagePath') 100 100 sessionFileList = os.listdir(storagePath) 101 101 … … 111 111 112 112 def _debugDump(self): 113 storagePath = self. settings.storagePath113 storagePath = self.getSetting('storagePath') 114 114 sessionFileList = os.listdir(storagePath) 115 115

