Changeset 1708
- Timestamp:
- 08/22/07 12:15:01
- Files:
-
- trunk/cherrypy/lib/sessions.py (modified) (2 diffs)
- trunk/cherrypy/test/test_session.py (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/cherrypy/lib/sessions.py
r1696 r1708 401 401 def save(): 402 402 """Save any changed session data.""" 403 if not hasattr(cherrypy, "session"): 403 404 if not hasattr(cherrypy._serving, "session"): 404 405 return 405 406 … … 423 424 def close(): 424 425 """Close the session object for this request.""" 425 sess = getattr(cherrypy , "session", None)426 sess = getattr(cherrypy._serving, "session", None) 426 427 if sess and sess.locked: 427 428 # If the session is still locked we release the lock trunk/cherrypy/test/test_session.py
r1596 r1708 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

