Changeset 1707
- Timestamp:
- 08/22/07 12:07:53
- Files:
-
- branches/cherrypy-3.0.x/cherrypy/lib/sessions.py (modified) (2 diffs)
- branches/cherrypy-3.0.x/cherrypy/test/test_session.py (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/cherrypy-3.0.x/cherrypy/lib/sessions.py
r1611 r1707 396 396 def save(): 397 397 """Save any changed session data.""" 398 399 if not hasattr(cherrypy._serving, "session"): 400 return 401 398 402 # Guard against running twice 399 403 if hasattr(cherrypy.request, "_sessionsaved"): … … 415 419 def close(): 416 420 """Close the session object for this request.""" 417 sess = cherrypy.session418 if sess .locked:421 sess = getattr(cherrypy._serving, "session", None) 422 if sess and sess.locked: 419 423 # If the session is still locked we release the lock 420 424 sess.release_lock() branches/cherrypy-3.0.x/cherrypy/test/test_session.py
r1596 r1707 10 10 import cherrypy 11 11 from cherrypy.lib import sessions 12 13 def http_methods_allowed(methods=['GET', 'HEAD']): 14 method = cherrypy.request.method.upper() 15 if method not in methods: 16 cherrypy.response.headers['Allow'] = ", ".join(methods) 17 raise cherrypy.HTTPError(405) 18 19 cherrypy.tools.allow = cherrypy.Tool('on_start_resource', http_methods_allowed) 12 20 13 21 … … 68 76 raise cherrypy.InternalRedirect('/blah') 69 77 iredir.exposed = True 78 79 @cherrypy.tools.allow(methods=['GET']) 80 def restricted(self): 81 return cherrypy.request.method 82 restricted.exposed = True 70 83 71 84 cherrypy.tree.mount(Root()) … … 175 188 os.unlink(path) 176 189 self.getPage('/testStr', self.cookies) 177 190 191 def test_5_Error_paths(self): 192 self.getPage('/unknown/page') 193 self.assertErrorPage(404, "The path '/unknown/page' was not found.") 194 195 # Note: this path is *not* the same as above. The above 196 # takes a normal route through the session code; this one 197 # skips the session code's before_handler and only calls 198 # before_finalize (save) and on_end (close). So the session 199 # code has to survive calling save/close without init. 200 self.getPage('/restricted', self.cookies, method='POST') 201 self.assertErrorPage(405, "Specified method is invalid for this server.") 178 202 179 203

