[FIX] http: nodb_routing_map become a lazy property. load_addons() is also lazy called

bzr revid: chs@openerp.com-20140324122610-dodj6tme5xpbkc3i
This commit is contained in:
Christophe Simonis 2014-03-24 13:26:10 +01:00
parent c8eddb7d22
commit 7c4557add2
1 changed files with 12 additions and 5 deletions

View File

@ -36,6 +36,7 @@ import werkzeug.wsgi
import openerp import openerp
from openerp.service import security, model as service_model from openerp.service import security, model as service_model
from openerp.tools.func import lazy_property
_logger = logging.getLogger(__name__) _logger = logging.getLogger(__name__)
@ -1077,22 +1078,28 @@ class Root(object):
path = openerp.tools.config.session_dir path = openerp.tools.config.session_dir
_logger.debug('HTTP sessions stored in: %s', path) _logger.debug('HTTP sessions stored in: %s', path)
self.session_store = werkzeug.contrib.sessions.FilesystemSessionStore(path, session_class=OpenERPSession) self.session_store = werkzeug.contrib.sessions.FilesystemSessionStore(path, session_class=OpenERPSession)
self._loaded = False
# TODO should we move this to ir.http so that only configured modules are served ? @lazy_property
_logger.info("HTTP Configuring static files") def nodb_routing_map(self):
self.load_addons()
_logger.info("Generating nondb routing") _logger.info("Generating nondb routing")
self.nodb_routing_map = routing_map([''] + openerp.conf.server_wide_modules, True) return routing_map([''] + openerp.conf.server_wide_modules, True)
def __call__(self, environ, start_response): def __call__(self, environ, start_response):
""" Handle a WSGI request """ Handle a WSGI request
""" """
if not self._loaded:
self.load_addons()
self._loaded = True
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 ?
_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: