Changeset 3979
- Timestamp:
- 01/20/08 07:59:42 (6 months ago)
- Files:
-
- branches/1.0/turbogears/identity/tests/test_identity.py (modified) (3 diffs)
- branches/1.0/turbogears/visit/api.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/1.0/turbogears/identity/tests/test_identity.py
r3974 r3979 116 116 new_user_setup = turbogears.expose()(new_user_setup) 117 117 118 _test_params = ('a=quark&b=krümel&c-0=sülze1&c-1=sülze2' 119 '&d.a=klöße1&d.b-0=klöße2&d.b-1=klöße3' 120 '&e-0=käse1&e-1.a=käse2&e-2.b-0=käse3&e-2.b-1=käse4') 118 _test_encoded_params = ('b=krümel&d.a=klöße1') 121 119 122 120 def test_params(self, **kwargs): 123 params = self._test_params 124 decode = formencode.variabledecode.variable_decode 125 params = decode(dict([p.split('=') for p in params.split('&')])) 126 127 if params == cherrypy.request.params: 121 params = self._test_encoded_params 122 # formencode's variable_decode create a datastructure 123 # but does not "decode" anything 124 to_datastruct = formencode.variabledecode.variable_decode 125 126 expected_params = to_datastruct(dict([p.split('=') for p in params.split('&')])) 127 128 params_ok = True 129 130 if not expected_params['b'].decode('utf8') == cherrypy.request.params['b']: 131 params_ok = False 132 133 if not expected_params['d']['a'].decode('utf8') == cherrypy.request.params['d']['a']: 134 params_ok = False 135 136 if params_ok: 128 137 return 'params ok' 138 129 139 else: 130 return 'wrong params: %s\nexpected : %s' % (131 params,cherrypy.request.params)140 return 'wrong params: %s\nexpected unicode objects for all strings' % ( 141 cherrypy.request.params) 132 142 133 143 test_params = turbogears.expose()(test_params) … … 464 474 """Test that the decode filter doesn't break with nested\ 465 475 variables and Identity""" 466 params = urllib.quote(IdentityRoot._test_ params.decode('utf-8').encode('latin-1'), '=&')476 params = urllib.quote(IdentityRoot._test_encoded_params.decode('utf-8').encode('latin-1'), '=&') 467 477 testutil.create_request('/test_params?' + params) 468 478 firstline = cherrypy.response.body[0] … … 472 482 """Test that the decode filter doesn't break with nested\ 473 483 variables and Identity""" 474 params = urllib.quote(IdentityRoot._test_ params.decode('utf-8').encode('latin-1'), '=&')484 params = urllib.quote(IdentityRoot._test_encoded_params.decode('utf-8').encode('latin-1'), '=&') 475 485 params += '&user_name=samIam&password=secret&login=Login' 476 486 testutil.create_request('/test_params?' + params) branches/1.0/turbogears/visit/api.py
r3974 r3979 118 118 # Interface for the TurboGears extension 119 119 def start_extension(): 120 # TODO: this should alway be active even when visit is not on, 121 # we should find a better place to load this code... 122 # Monkey patch CP Decoding filter 123 from cherrypy.filters import decodingfilter 124 # TODO: is there a better way to inject this ? Maybe earlier than start_extension 125 # monkey inject our replacement filter into the CP2 filter chain 126 df = MonkeyDecodingFilter() 127 for index, active_filter in enumerate( 128 cherrypy.filters._filterhooks.get('before_main', [])): 129 130 if active_filter.im_class == \ 131 cherrypy.filters.decodingfilter.DecodingFilter: 132 133 cherrypy.filters._filterhooks['before_main'].pop(index) 134 cherrypy.filters._filterhooks['before_main'].insert( 135 index, df.before_main) 136 137 # Here is the real visit code. 120 138 # Bail out if the application hasn't enabled this extension 121 139 if not turbogears.config.get("visit.on", False): … … 125 143 if _manager: 126 144 return 127 128 # Monkey patch CP Decoding filter129 from cherrypy.filters import decodingfilter130 # TODO: is there a better way to inject this ? Maybe earlier than start_extension131 # monkey inject our replacement filter into the CP2 filter chain132 df = MonkeyDecodingFilter()133 for index, active_filter in enumerate(134 cherrypy.filters._filterhooks.get('before_main', [])):135 136 if active_filter.im_class == \137 cherrypy.filters.decodingfilter.DecodingFilter:138 139 cherrypy.filters._filterhooks['before_main'].pop(index)140 cherrypy.filters._filterhooks['before_main'].insert(141 index, df.before_main)142 145 143 146 log.info("Visit Tracking starting")