summaryrefslogtreecommitdiff
path: root/addons
diff options
context:
space:
mode:
authorAntony Lesuisse <al@openerp.com>2012-07-18 16:22:35 +0200
committerAntony Lesuisse <al@openerp.com>2012-07-18 16:22:35 +0200
commite0aafd1c5ebffe791fddf07c01b71b1cc52cd24a (patch)
tree0293bf96e3b5cc8b100f72d674f69a7029a47448 /addons
parent5808220f2a3ad6408f8dbd30bbbb5fdaaeadb83c (diff)
[FIX] Disable cache middleware for debug mode
bzr revid: al@openerp.com-20120718142235-x4uwzsar7ak6sxgk
Diffstat (limited to 'addons')
-rw-r--r--addons/web/common/http.py18
1 files changed, 16 insertions, 2 deletions
diff --git a/addons/web/common/http.py b/addons/web/common/http.py
index cc76a554693..7b73c2169ea 100644
--- a/addons/web/common/http.py
+++ b/addons/web/common/http.py
@@ -417,6 +417,20 @@ class ControllerType(type):
class Controller(object):
__metaclass__ = ControllerType
+class DisableCacheMiddleware(object):
+ def __init__(self, app):
+ self.app = app
+ def __call__(self, environ, start_response):
+ def start_wrapped(status, headers):
+ debug = environ.get('HTTP_REFERER', '').find('debug') != -1
+ filtered_headers = [(k,v) for k,v in headers if not (k=='Last-Modified' or (debug and k=='Cache-Control'))]
+ if debug:
+ filtered_headers.append(('Cache-Control', 'no-cache'))
+ print headers
+ print filtered_headers
+ start_response(status, filtered_headers)
+ return self.app(environ, start_wrapped)
+
class Root(object):
"""Root WSGI application for the OpenERP Web Client.
@@ -452,8 +466,8 @@ class Root(object):
static_dirs = self._load_addons(openerp_addons_namespace)
if options.serve_static:
- self.dispatch = werkzeug.wsgi.SharedDataMiddleware(
- self.dispatch, static_dirs, cache=False)
+ app = werkzeug.wsgi.SharedDataMiddleware( self.dispatch, static_dirs)
+ self.dispatch = DisableCacheMiddleware(app)
if options.session_storage:
if not os.path.exists(options.session_storage):