Author: chrisz
Date: Tue Jan 11 08:49:16 2011
New Revision: 7200
URL: http://trac.turbogears.org/changeset/7200

Log:
Some fixes for running with CherryPy 3.2.

Modified:
   branches/1.5/turbogears/identity/base.py
   branches/1.5/turbogears/identity/tests/test_identity.py
   branches/1.5/turbogears/startup.py

Modified: branches/1.5/turbogears/identity/base.py
==============================================================================
--- branches/1.5/turbogears/identity/base.py    Tue Jan 11 07:33:19 2011        
(r7199)
+++ branches/1.5/turbogears/identity/base.py    Tue Jan 11 08:49:16 2011        
(r7200)
@@ -214,8 +214,8 @@
     Does not override status if the login controller errors out.
 
     """
-
-    if (str(cherrypy.response.status) < '400'):
+    status = cherrypy.response.status
+    if not status or str(status) < '400':
         new_status = cherrypy.request.wsgi_environ.get('identity_status')
         if new_status:
             cherrypy.response.status = new_status

Modified: branches/1.5/turbogears/identity/tests/test_identity.py
==============================================================================
--- branches/1.5/turbogears/identity/tests/test_identity.py     Tue Jan 11 
07:33:19 2011        (r7199)
+++ branches/1.5/turbogears/identity/tests/test_identity.py     Tue Jan 11 
08:49:16 2011        (r7200)
@@ -250,7 +250,7 @@
     def new_user_setup(self, user_name, password):
         return '%s %s' % (user_name, password)
 
-    _test_encoded_params = ('b=krümel&d.a=klöße1')
+    _test_encoded_params = 'b=krümel&d.a=klöße1'
 
     @expose()
     @identity.require(not_anonymous())
@@ -631,16 +631,14 @@
     def test_decode_filter_whenidfails(self):
         """Test that the decode filter doesn't break with nested
         variables and Identity"""
-        params = urllib.quote(IdentityRoot._test_encoded_params.decode(
-            'utf-8').encode('latin-1'), '=&')
+        params = urllib.quote(IdentityRoot._test_encoded_params, '=&')
         response = self.app.get('/test_params?' + params, status=403)
         assert 'identity_failed_answer' in response, response
 
     def test_decode_filter_whenidworks(self):
         """Test that the decode filter doesn't break with nested
         variables and Identity"""
-        params = urllib.quote(IdentityRoot._test_encoded_params.decode(
-            'utf-8').encode('latin-1'), '=&')
+        params = urllib.quote(IdentityRoot._test_encoded_params, '=&')
         params += '&user_name=samIam&password=secret&login=Login'
         response = self.app.get('/test_params?' + params)
         assert 'params ok' in response, response

Modified: branches/1.5/turbogears/startup.py
==============================================================================
--- branches/1.5/turbogears/startup.py  Tue Jan 11 07:33:19 2011        (r7199)
+++ branches/1.5/turbogears/startup.py  Tue Jan 11 08:49:16 2011        (r7200)
@@ -161,7 +161,7 @@
     if config.get('visit.on', False):
         cherrypy.tools.visit = cherrypy.Tool('before_handler', VisitTool())
     hooks = cherrypy.request.hooks
-    hooks.attach('on_end_resource', verify_identity_status)
+    hooks.attach('before_finalize', verify_identity_status)
     hooks.attach('on_end_resource', database.EndTransactions)
     # The NestedVariablesHook needs to happen after cherrypy.tools.decode
     # in order to be decoded properly.

Reply via email to