diff --git a/addons/web/http.py b/addons/web/http.py index 25cbecc56fc..8595e38446f 100644 --- a/addons/web/http.py +++ b/addons/web/http.py @@ -478,10 +478,9 @@ class Root(object): """ def __init__(self): self.addons = {} + self.statics = {} - static_dirs = self._load_addons() - app = werkzeug.wsgi.SharedDataMiddleware( self.dispatch, static_dirs) - self.dispatch = DisableCacheMiddleware(app) + self.load_addons() # Setup http sessions path = session_path() @@ -530,12 +529,10 @@ class Root(object): return response(environ, start_response) - def _load_addons(self): - """ - Loads all addons at the specified addons path, returns a mapping of - static URLs to the corresponding directories - """ - statics = {} + def load_addons(self): + """ Load all addons from addons patch containg static files and + controllers and configure them. """ + for addons_path in openerp.modules.module.ad_paths: for module in sorted(os.listdir(addons_path)): if module not in addons_module: @@ -551,14 +548,17 @@ class Root(object): m = __import__(module) addons_module[module] = m addons_manifest[module] = manifest - statics['/%s/static' % module] = path_static + self.statics['/%s/static' % module] = path_static + for k, v in controllers_class: if k not in controllers_object: o = v() controllers_object[k] = o if hasattr(o, '_cp_path'): controllers_path[o._cp_path] = o - return statics + + app = werkzeug.wsgi.SharedDataMiddleware(self.dispatch, self.statics) + self.dispatch = DisableCacheMiddleware(app) def find_handler(self, *l): """ diff --git a/addons/web/static/src/css/base.css b/addons/web/static/src/css/base.css index 39bb5d8c5d9..7e8242a8d5c 100644 --- a/addons/web/static/src/css/base.css +++ b/addons/web/static/src/css/base.css @@ -819,6 +819,16 @@ margin-top: 1px; background-color: #f6cf3b; } +.openerp .oe_dialog_warning { + width: 100%; +} +.openerp .oe_dialog_warning p { + text-align: center; +} +.openerp .oe_dialog_icon { + padding: 5px; + width: 32px; +} .openerp .oe_login { background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAYAAAAGCAYAAADgzO9IAAAAKUlEQVQIHWO8e/fufwYsgAUkJigoiCIF5DMyoYggcUiXgNnBiGQKmAkARpcEQeriln4AAAAASUVORK5CYII=); text-align: center; diff --git a/addons/web/static/src/css/base.sass b/addons/web/static/src/css/base.sass index eab40a5b5bd..0369f5fd4b5 100644 --- a/addons/web/static/src/css/base.sass +++ b/addons/web/static/src/css/base.sass @@ -696,6 +696,15 @@ $sheet-padding: 16px margin-top: 1px background-color: #f6cf3b // }}} + // CrashManager {{{ + .oe_dialog_warning + width: 100% + p + text-align: center + .oe_dialog_icon + padding: 5px + width: 32px + // }}} // Login {{{ .oe_login background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAYAAAAGCAYAAADgzO9IAAAAKUlEQVQIHWO8e/fufwYsgAUkJigoiCIF5DMyoYggcUiXgNnBiGQKmAkARpcEQeriln4AAAAASUVORK5CYII=) diff --git a/addons/web/static/src/js/chrome.js b/addons/web/static/src/js/chrome.js index 4ad159e3ac5..632e782c67c 100644 --- a/addons/web/static/src/js/chrome.js +++ b/addons/web/static/src/js/chrome.js @@ -691,6 +691,7 @@ instance.web.Login = instance.web.Widget.extend({ }); instance.web.client_actions.add("login", "instance.web.Login"); + /** * Redirect to url by replacing window.location * If wait is true, sleep 1s and wait for the server i.e. after a restart. @@ -1368,17 +1369,17 @@ instance.web.EmbeddedClient = instance.web.Client.extend({ _template: 'EmbedClient', init: function(parent, origin, dbname, login, key, action_id, options) { this._super(parent, origin); - - this.dbname = dbname; - this.login = login; - this.key = key; + this.bind_credentials(dbname, login, key); this.action_id = action_id; this.options = options || {}; }, start: function() { var self = this; return $.when(this._super()).then(function() { - return instance.session.session_authenticate(self.dbname, self.login, self.key, true).then(function() { + return self.authenticate().then(function() { + if (!self.action_id) { + return; + } return self.rpc("/web/action/load", { action_id: self.action_id }).done(function(result) { var action = result; action.flags = _.extend({ @@ -1389,11 +1390,30 @@ instance.web.EmbeddedClient = instance.web.Client.extend({ //pager : false }, self.options, action.flags || {}); - self.action_manager.do_action(action); + self.do_action(action); }); }); }); }, + + do_action: function(action) { + return this.action_manager.do_action(action); + }, + + authenticate: function() { + var s = instance.session; + if (s.session_is_valid() && s.db === this.dbname && s.login === this.login) { + return $.when(); + } + return instance.session.session_authenticate(this.dbname, this.login, this.key, true); + }, + + bind_credentials: function(dbname, login, key) { + this.dbname = dbname; + this.login = login; + this.key = key; + }, + }); instance.web.embed = function (origin, dbname, login, key, action, options) { diff --git a/addons/web/static/src/js/coresetup.js b/addons/web/static/src/js/coresetup.js index c88e0ca0512..eac26520301 100644 --- a/addons/web/static/src/js/coresetup.js +++ b/addons/web/static/src/js/coresetup.js @@ -30,6 +30,12 @@ instance.web.Session = instance.web.JsonRPC.extend( /** @lends instance.web.Sess * Setup a sessionm */ session_bind: function(origin) { + if (!_.isUndefined(this.origin)) { + if (this.origin === origin) { + return $.when(); + } + throw new Error('Session already bound to ' + this.origin); + } var self = this; this.setup(origin); instance.web.qweb.default_dict['_s'] = this.origin; diff --git a/addons/web/static/src/xml/base.xml b/addons/web/static/src/xml/base.xml index 5afadaeffd0..82714c22aa8 100644 --- a/addons/web/static/src/xml/base.xml +++ b/addons/web/static/src/xml/base.xml @@ -36,11 +36,11 @@ - +

- var message = d.message ? d.message : d.error.data.fault_code; + var message = d.error.message ? d.error.message : d.error.data.fault_code; d.html_error = context.engine.tools.html_escape(message) .replace(/\n/g, '
');