[MERGE] rename Session into connection define a Connection singleton (chs)
authorAntony Lesuisse <al@openerp.com>
Tue, 8 Nov 2011 15:27:23 +0000 (16:27 +0100)
committerAntony Lesuisse <al@openerp.com>
Tue, 8 Nov 2011 15:27:23 +0000 (16:27 +0100)
bzr revid: al@openerp.com-20111108152723-2w6zpksjw4e1yx7q

1  2 
addons/web/static/src/js/chrome.js
addons/web/static/src/js/core.js
addons/web/static/src/js/data.js

@@@ -136,10 -136,10 +136,10 @@@ openerp.web.Dialog = openerp.web.OldWid
      }
  });
  
- 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);
++        openerp.connection.on_rpc_error.add(this.on_rpc_error);
      },
      on_rpc_error: function(error) {
          this.error = error;
@@@ -828,7 -797,8 +796,8 @@@ openerp.web.Widget = openerp.web.Callba
       * 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;
++        this.session = openerp.connection;
          // 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;
      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() {
++        openerp.connection.rpc(url, data). then(function() {
              if (!self.widget_is_stopped)
                  def.resolve.apply(def, arguments);
          }, function() {
@@@ -1047,6 -1017,6 +1016,11 @@@ if ($.blockUI) 
      $.blockUI.defaults.baseZ = 1100;
      $.blockUI.defaults.message = '<img src="/web/static/src/img/throbber2.gif">';
  }
++
++/** Setup default connection */
++openerp.connection = new openerp.web.Connection();
++
++/** Configure default qweb */
  openerp.web._t = new openerp.web.TranslationDataBase().build_translation_function();
  openerp.web.qweb = new QWeb2.Engine();
  openerp.web.qweb.debug = (window.location.search.indexOf('?debug') !== -1);
@@@ -785,11 -785,15 +785,15 @@@ openerp.web.ProxyDataSet = openerp.web.
      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;
++        var c = openerp.connection;
+         return c.rpc.apply(c, arguments);
+     },
      get_func: function(method_name) {
          var self = this;
          return function() {