From 64571fa4ab444b899629d57ccfe54e875ddaaf59 Mon Sep 17 00:00:00 2001 From: niv-openerp Date: Fri, 12 Aug 2011 12:19:52 +0200 Subject: [PATCH] [imp] refactoring of Session to not inherit Widget anymore bzr revid: nicolas.vanhoren@openerp.com-20110812101952-qw12p8xhdfa3kmzu --- addons/base/static/src/js/boot.js | 1 + addons/base/static/src/js/chrome.js | 2 +- addons/base/static/src/js/core.js | 31 +++++++++++++++++------------ 3 files changed, 20 insertions(+), 14 deletions(-) diff --git a/addons/base/static/src/js/boot.js b/addons/base/static/src/js/boot.js index 3d1d1e75e7c..2791bf2bc27 100644 --- a/addons/base/static/src/js/boot.js +++ b/addons/base/static/src/js/boot.js @@ -53,6 +53,7 @@ *---------------------------------------------------------*/ openerp.base = function(instance) { + openerp.base._t = function(x) { return x; }; openerp.base.core(instance); openerp.base.formats(instance); openerp.base.chrome(instance); diff --git a/addons/base/static/src/js/chrome.js b/addons/base/static/src/js/chrome.js index 7e7f5ae6ab6..49d2099c948 100644 --- a/addons/base/static/src/js/chrome.js +++ b/addons/base/static/src/js/chrome.js @@ -681,7 +681,7 @@ openerp.base.WebClient = openerp.base.Widget.extend({ } this.$element.html(QWeb.render("Interface", params)); - this.session = new openerp.base.Session(this,"oe_errors"); + this.session = new openerp.base.Session(); this.loading = new openerp.base.Loading(this,"oe_loading"); this.crashmanager = new openerp.base.CrashManager(this); this.crashmanager.start(); diff --git a/addons/base/static/src/js/core.js b/addons/base/static/src/js/core.js index 859c96645a1..7f294775410 100644 --- a/addons/base/static/src/js/core.js +++ b/addons/base/static/src/js/core.js @@ -305,16 +305,8 @@ openerp.base.Registry = openerp.base.Class.extend( /** @lends openerp.base.Regis } }); -/** - * Utility class that any class is allowed to extend to easy common manipulations. - * - * It provides rpc calls, callback on all methods preceded by "on_" or "do_" and a - * logging facility. - */ -openerp.base.SessionAware = openerp.base.Class.extend({ - init: function(session) { - this.session = session; - +openerp.base.CallbackEnabled = openerp.base.Class.extend({ + init: function() { // Transform on_* method into openerp.base.callbacks for (var name in this) { if(typeof(this[name]) == "function") { @@ -325,6 +317,19 @@ openerp.base.SessionAware = openerp.base.Class.extend({ } } } + } +}); + +/** + * Utility class that any class is allowed to extend to easy common manipulations. + * + * It provides rpc calls, callback on all methods preceded by "on_" or "do_" and a + * logging facility. + */ +openerp.base.SessionAware = openerp.base.CallbackEnabled.extend({ + init: function(session) { + this._super(); + this.session = session; }, /** * Performs a JSON-RPC call @@ -611,15 +616,15 @@ openerp.base.OldWidget = openerp.base.Widget.extend({ } }); -openerp.base.Session = openerp.base.Widget.extend( /** @lends openerp.base.Session# */{ +openerp.base.Session = openerp.base.CallbackEnabled.extend( /** @lends openerp.base.Session# */{ /** * @constructs * @param element_id to use for exception reporting * @param server * @param port */ - init: function(parent, element_id, server, port) { - this._super(parent, element_id); + init: function(server, port) { + this._super(); this.server = (server == undefined) ? location.hostname : server; this.port = (port == undefined) ? location.port : port; this.rpc_mode = (server == location.hostname) ? "ajax" : "jsonp";