[FIX] http: when generating static routes, only wrap dispatcher only if there is any new static directory found

bzr revid: chs@openerp.com-20140324161257-fi1cpgyd97825b14
This commit is contained in:
Christophe Simonis 2014-03-24 17:12:57 +01:00
parent e5f645df4d
commit a8e1aba23b
1 changed files with 7 additions and 6 deletions

View File

@ -1089,17 +1089,14 @@ class Root(object):
""" Handle a WSGI request """ Handle a WSGI request
""" """
if not self._loaded: if not self._loaded:
self.load_addons()
self._loaded = True self._loaded = True
self.load_addons()
return self.dispatch(environ, start_response) return self.dispatch(environ, start_response)
def load_addons(self): def load_addons(self):
""" Load all addons from addons patch containg static files and """ Load all addons from addons patch containg static files and
controllers and configure them. """ controllers and configure them. """
# TODO should we move this to ir.http so that only configured modules are served ? # TODO should we move this to ir.http so that only configured modules are served ?
_logger.info("HTTP Configuring static files")
self.__dict__.pop('dispatch', None)
statics = {} statics = {}
for addons_path in openerp.modules.module.ad_paths: for addons_path in openerp.modules.module.ad_paths:
@ -1113,12 +1110,16 @@ class Root(object):
_logger.debug("Loading %s", module) _logger.debug("Loading %s", module)
if 'openerp.addons' in sys.modules: if 'openerp.addons' in sys.modules:
m = __import__('openerp.addons.' + module) m = __import__('openerp.addons.' + module)
else:
m = None
addons_module[module] = m addons_module[module] = m
addons_manifest[module] = manifest addons_manifest[module] = manifest
statics['/%s/static' % module] = path_static statics['/%s/static' % module] = path_static
app = werkzeug.wsgi.SharedDataMiddleware(self.dispatch, statics) if statics:
self.dispatch = DisableCacheMiddleware(app) _logger.info("HTTP Configuring static files")
app = werkzeug.wsgi.SharedDataMiddleware(self.dispatch, statics)
self.dispatch = DisableCacheMiddleware(app)
def setup_session(self, httprequest): def setup_session(self, httprequest):
# recover or create session # recover or create session