OpenERP Online has proposed merging
lp:~openerp-dev/openerp-web/trunk-connection-chs into lp:openerp-web.
Requested reviews:
OpenERP R&D Web Team (openerp-dev-web)
For more details, see:
https://code.launchpad.net/~openerp-dev/openerp-web/trunk-connection-chs/+merge/81000
--
https://code.launchpad.net/~openerp-dev/openerp-web/trunk-connection-chs/+merge/81000
Your team OpenERP R&D Team is subscribed to branch
lp:~openerp-dev/openerp-web/trunk-connection-chs.
=== modified file 'addons/web/static/src/js/boot.js'
--- addons/web/static/src/js/boot.js 2011-09-27 11:14:02 +0000
+++ addons/web/static/src/js/boot.js 2011-11-02 11:08:27 +0000
@@ -21,7 +21,16 @@
*
* @param {Array} modules list of modules to initialize
*/
- init: function(modules) {
+ init: function(modules, connection, callback) {
+
+ if (/^(function|undefined)$/.test(typeof connection)) {
+ callback = connection;
+ connection = {
+ host: document.location.protocol + '//' + document.location.host,
+ };
+ }
+
+
var new_instance = {
// links to the global openerp
_openerp: openerp,
@@ -39,6 +48,20 @@
for(var i=0; i < modules.length; i++) {
openerp[modules[i]](new_instance);
}
+
+ new_instance.connector = new new_instance.web.Connection(connection.host);
+ if (connection.login) {
+ new_instance.connector.login(connection.database, connection.login, connection.password, function() {
+ if (callback) {
+ callback(new_instance);
+ }
+ });
+ } else {
+ if (callback) {
+ callback(new_instance);
+ }
+ }
+
return new_instance;
}
};
=== modified file 'addons/web/static/src/js/chrome.js'
--- addons/web/static/src/js/chrome.js 2011-10-28 08:52:12 +0000
+++ addons/web/static/src/js/chrome.js 2011-11-02 11:08:27 +0000
@@ -136,10 +136,10 @@
}
});
-openerp.web.CrashManager = openerp.web.SessionAware.extend({
- init: function(parent) {
- this._super((parent || {}).session);
- this.session.on_rpc_error.add(this.on_rpc_error);
+openerp.web.CrashManager = openerp.web.CallbackEnabled.extend({
+ init: function() {
+ this._super();
+ openerp.connector.on_rpc_error.add(this.on_rpc_error);
},
on_rpc_error: function(error) {
this.error = error;
@@ -967,9 +967,8 @@
this.$element.html(QWeb.render("Interface", params));
this.notification = new openerp.web.Notification();
- this.session = new openerp.web.Session();
this.loading = new openerp.web.Loading(this,"oe_loading");
- this.crashmanager = new openerp.web.CrashManager(this);
+ this.crashmanager = new openerp.web.CrashManager();
this.header = new openerp.web.Header(this);
this.login = new openerp.web.Login(this);
=== modified file 'addons/web/static/src/js/core.js'
--- addons/web/static/src/js/core.js 2011-10-27 12:45:03 +0000
+++ addons/web/static/src/js/core.js 2011-11-02 11:08:27 +0000
@@ -237,8 +237,8 @@
* registry was created.
*
* An object path is simply a dotted name from the openerp root to the
- * object pointed to (e.g. ``"openerp.web.Session"`` for an OpenERP
- * session object).
+ * object pointed to (e.g. ``"openerp.web.Connection"`` for an OpenERP
+ * connection object).
*
* @constructs openerp.web.Registry
* @param {Object} mapping a mapping of keys to object-paths
@@ -338,9 +338,9 @@
}
});
-openerp.web.Session = openerp.web.CallbackEnabled.extend( /** @lends openerp.web.Session# */{
+openerp.web.Connection = openerp.web.CallbackEnabled.extend( /** @lends openerp.web.Connection# */{
/**
- * @constructs openerp.web.Session
+ * @constructs openerp.web.Connection
* @extends openerp.web.CallbackEnabled
*
* @param {String} [server] JSON-RPC endpoint hostname
@@ -490,6 +490,7 @@
return true;
}).then(success_callback);
},
+ login: function() { this.session_login.apply(this, arguments); },
/**
* Reloads uid and session_id from local storage, if they exist
*/
@@ -716,36 +717,6 @@
}
});
-openerp.web.SessionAware = openerp.web.CallbackEnabled.extend(/** @lends openerp.web.SessionAware# */{
- /**
- * 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.
- *
- * @constructs openerp.web.SessionAware
- * @extends openerp.web.CallbackEnabled
- *
- * @param {openerp.web.Session} session
- */
- init: function(session) {
- this._super();
- this.session = session;
- },
- /**
- * Performs a JSON-RPC call
- *
- * @param {String} url endpoint url
- * @param {Object} data RPC parameters
- * @param {Function} success RPC call success callback
- * @param {Function} error RPC call error callback
- * @returns {jQuery.Deferred} deferred object for the RPC call
- */
- rpc: function(url, data, success, error) {
- return this.session.rpc(url, data, success, error);
- }
-});
-
/**
* Base class for all visual components. Provides a lot of functionalities helpful
* for the management of a part of the DOM.
@@ -756,8 +727,6 @@
* destroyed too).
* - Insertion in DOM.
*
- * Widget also extends SessionAware for ease of use.
- *
* Guide to create implementations of the Widget class:
* ==============================================
*
@@ -798,7 +767,7 @@
*
* That will kill the widget in a clean way and erase its content from the dom.
*/
-openerp.web.Widget = openerp.web.SessionAware.extend(/** @lends openerp.web.Widget# */{
+openerp.web.Widget = openerp.web.CallbackEnabled.extend(/** @lends openerp.web.Widget# */{
/**
* The name of the QWeb template that will be used for rendering. Must be
* redefined in subclasses or the default render() method can not be used.
@@ -817,7 +786,7 @@
* Construct the widget and set its parent if a parent is given.
*
* @constructs openerp.web.Widget
- * @extends openerp.web.SessionAware
+ * @extends openerp.web.CallbackEnabled
*
* @param {openerp.web.Widget} parent Binds the current instance to the given Widget instance.
* When that widget is destroyed by calling stop(), the current instance will be
@@ -828,7 +797,8 @@
* for new components this argument should not be provided any more.
*/
init: function(parent, /** @deprecated */ element_id) {
- this._super((parent || {}).session);
+ this._super();
+ this.session = openerp.connector;
// if given an element_id, try to get the associated DOM element and save
// a reference in this.$element. Else just generate a unique identifier.
this.element_id = element_id;
@@ -967,7 +937,7 @@
rpc: function(url, data, success, error) {
var def = $.Deferred().then(success, error);
var self = this;
- this._super(url, data). then(function() {
+ openerp.connector.rpc(url, data). then(function() {
if (!self.widget_is_stopped)
def.resolve.apply(def, arguments);
}, function() {
=== modified file 'addons/web/static/src/js/data.js'
--- addons/web/static/src/js/data.js 2011-10-21 12:06:45 +0000
+++ addons/web/static/src/js/data.js 2011-11-02 11:08:27 +0000
@@ -32,7 +32,7 @@
* @constructs openerp.web.DataGroup
* @extends openerp.web.Widget
*
- * @param {openerp.web.Session} session Current OpenERP session
+ * @param {openerp.web.Widget} parent widget
* @param {String} model name of the model managed by this DataGroup
* @param {Array} domain search domain for this DataGroup
* @param {Object} context context of the DataGroup's searches
@@ -785,11 +785,15 @@
on_unlink: function(ids) {}
});
-openerp.web.Model = openerp.web.SessionAware.extend({
- init: function(session, model_name) {
- this._super(session);
+openerp.web.Model = openerp.web.CallbackEnabled.extend({
+ init: function(_, model_name) {
+ this._super();
this.model_name = model_name;
},
+ rpc: function() {
+ var c = openerp.connector;
+ return c.rpc.apply(c, arguments);
+ },
get_func: function(method_name) {
var self = this;
return function() {
_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help : https://help.launchpad.net/ListHelp