Joel Rivera  committed 7d7cb45

Improve fix for the bug of the json tools and caching,
this is more general and no tightly bound to
the caching tool. Fixing issue #1237.

  • Participants
  • Parent commits 21be188
  • Branches default

Comments (0)

Files changed (1)

File cherrypy/lib/

         request.body.processors[ct] = processor
 def json_handler(*args, **kwargs):
-    request = cherrypy.serving.request
-    if getattr(request, 'cached', False):
-        return cherrypy.serving.response.body
-    value = request._json_inner_handler(*args, **kwargs)
+    value = cherrypy.serving.request._json_inner_handler(*args, **kwargs)
     return json_encode(value)
 def json_out(content_type='application/json', debug=False, handler=json_handler):
     package importable; otherwise, ValueError is raised during processing.
     request = cherrypy.serving.request
+    # request.handler may be set to None by e.g. the caching tool
+    # to signal to all components that a response body has already
+    # been attached, in which case we don't need to wrap anything.
+    if request.handler is None:
+        return
     if debug:
         cherrypy.log('Replacing %s with JSON handler' % request.handler,