percious  committed 26a135c Merge

unfixed the json fix fix.

  • Participants
  • Parent commits 6cdd4c4, ae50e91

Comments (0)

Files changed (4)

 syntax: regexp

File tg/controllers/

 from tg.render import render as tg_render
 from tg.decorators import expose
 from tg.flash import flash
-from tg.jsonify import JsonEncodeError, is_saobject
+from tg.jsonify import is_saobject
 from util import pylons_formencode_gettext
-        pylons.request.start_response = self.start_response
+        pylons.request.start_response = getattr(self, 'start_response', None)
         remainder = remainder or []
         if content_type is not None: 
             pylons.response.headers['Content-Type'] = content_type
-        # skip all the complicated stuff if we're don't have a dict-like object
-        # to work with.
-        try:
-            value = response['test']
-        except TypeError:
-            #json-defined objects must be dict-like
-            if engine_name == 'json' and not hasattr(response, '__json__') and not isinstance(response, basestring) and not is_saobject(response):
-                raise JsonEncodeError('Your Encoded object must be dict-like.')
+        # if it's a string return that string and skip all the stuff
+        if not isinstance(response, dict):
             return response
-        except:
-            pass
         """Return a JSON string representation of a Python object."""
             error_handler = controller
             output = error_handler(*remainder, **dict(params))
         elif hasattr(error_handler, 'im_self') and error_handler.im_self != controller:
-            output = error_handler(*remainder, **dict(params))
+            output = error_handler(error_handler.im_self, *remainder, **dict(params))
             output = error_handler(controller.im_self, *remainder, **dict(params))

File tg/controllers/

         if pylons.config.get('i18n_enabled', True):
-        url_path = pylons.request.path.split('/')[1:]
+        script_name = pylons.request.environ.get('SCRIPT_NAME', '')
+        url_path = pylons.request.path
+        if url_path.startswith(script_name):
+            url_path = url_path[len(script_name):]
+        url_path = url_path.split('/')[1:]
         if url_path[-1] == '':

File tg/tests/

 from wsgiref.simple_server import demo_app
 from wsgiref.validate import validator
+from pylons import config
+config['renderers'] = ['genshi', 'mako', 'json']
 def setup():
 def teardown():
     def stacked_expose(self):
         return dict(got_json=True)
     def bad_json(self):
         return [(1, 'a'), 'b']
     def test_response_type(self):
         r ='/stacked_expose.json')
-        assert 'got_json' in r, r
+        assert 'got_json' in r.body, r
     def test_multi_value_kw(self):
         r ='/multi_value_kws?foo=1&foo=2')
         assert 'PNG' in resp, resp
         assert resp.headers['Content-Type'] == 'image/png', resp
-    @raises(tg.jsonify.JsonEncodeError)
-    def test_bad_json(self):
-        resp ='/bad_json')
-        assert 'ab' not in resp.body, resp