From a7adac1189d062ad8797b8d7ead929b27715cf3c Mon Sep 17 00:00:00 2001 From: niv-openerp Date: Thu, 11 Jul 2013 12:34:22 +0200 Subject: Now OpenERPSession is a subclass of werkzeug's session bzr revid: nicolas.vanhoren@openerp.com-20130711103422-w7y05ox7tq0hz0og --- addons/web/static/src/js/chrome.js | 2 +- addons/web/static/src/js/coresetup.js | 6 +----- 2 files changed, 2 insertions(+), 6 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/chrome.js b/addons/web/static/src/js/chrome.js index 0c73a9b8a3c..1c976cb619e 100644 --- a/addons/web/static/src/js/chrome.js +++ b/addons/web/static/src/js/chrome.js @@ -1599,7 +1599,7 @@ instance.web.EmbeddedClient = instance.web.Client.extend({ 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); + return instance.session.session_authenticate(this.dbname, this.login, this.key); }, bind_credentials: function(dbname, login, key) { diff --git a/addons/web/static/src/js/coresetup.js b/addons/web/static/src/js/coresetup.js index 7d37dc2261d..81de547d0c1 100644 --- a/addons/web/static/src/js/coresetup.js +++ b/addons/web/static/src/js/coresetup.js @@ -58,7 +58,7 @@ instance.web.Session = instance.web.JsonRPC.extend( /** @lends instance.web.Sess session_init: function () { var self = this; // TODO: session store in cookie should be optional - this.session_id = this.get_cookie('session_id'); + this.session_id = this.get_cookie('sid'); return this.session_reload().then(function(result) { var modules = instance._modules.join(','); var deferred = self.rpc('/web/webclient/qweblist', {mods: modules}).then(self.load_qweb.bind(self)); @@ -107,14 +107,10 @@ instance.web.Session = instance.web.JsonRPC.extend( /** @lends instance.web.Sess return $.Deferred().reject(); } _.extend(self, result); - if (!_volatile) { - self.set_cookie('session_id', self.session_id); - } return self.load_modules(); }); }, session_logout: function() { - this.set_cookie('session_id', ''); $.bbq.removeState(); return this.rpc("/web/session/destroy", {}); }, -- cgit v1.2.3 From 47b5a82ae85e795ae888799426f098066583ecbc Mon Sep 17 00:00:00 2001 From: niv-openerp Date: Thu, 11 Jul 2013 14:20:34 +0200 Subject: Completely removed all ways to specify session identifiers and reduced them to 2 possibilities: * The http argument 'session_id' (higher priority) * The cookie 'session_id' (lower priority) bzr revid: nicolas.vanhoren@openerp.com-20130711122034-3nvmkw4q5z4io4tm --- addons/web/static/src/js/corelib.js | 10 +++------- addons/web/static/src/js/coresetup.js | 3 +-- 2 files changed, 4 insertions(+), 9 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/corelib.js b/addons/web/static/src/js/corelib.js index 116ddf2e8c2..01ff92c88a0 100644 --- a/addons/web/static/src/js/corelib.js +++ b/addons/web/static/src/js/corelib.js @@ -1068,13 +1068,12 @@ instance.web.JsonRPC = instance.web.Class.extend(instance.web.PropertiesMixin, { var data = { session_id: this.session_id, id: payload.id, - sid: this.httpsessionid, }; var set_sid = function (response, textStatus, jqXHR) { // If response give us the http session id, we store it for next requests... - if (response.httpsessionid) { - self.httpsessionid = response.httpsessionid; + if (response.session_id) { + self.session_id = response.session_id; } }; @@ -1090,7 +1089,7 @@ instance.web.JsonRPC = instance.web.Class.extend(instance.web.PropertiesMixin, { ajax.async = false; var payload_str = JSON.stringify(payload); var payload_url = $.param({r:payload_str}); - if(payload_url.length < 2000) { + if (payload_url.length < 2000) { // Direct jsonp request ajax.data.r = payload_str; return $.ajax(ajax).done(set_sid); @@ -1139,9 +1138,6 @@ instance.web.JsonRPC = instance.web.Class.extend(instance.web.PropertiesMixin, { var qs = ''; if (!_.isNull(params)) { params = _.extend(params || {}, {session_id: this.session_id}); - if (this.httpsessionid) { - params.sid = this.httpsessionid; - } qs = '?' + $.param(params); } var prefix = _.any(['http://', 'https://', '//'], _.bind(_.str.startsWith, null, path)) ? '' : this.prefix; diff --git a/addons/web/static/src/js/coresetup.js b/addons/web/static/src/js/coresetup.js index 81de547d0c1..f153d3ad73a 100644 --- a/addons/web/static/src/js/coresetup.js +++ b/addons/web/static/src/js/coresetup.js @@ -23,7 +23,6 @@ instance.web.Session = instance.web.JsonRPC.extend( /** @lends instance.web.Sess this.qweb_mutex = new $.Mutex(); }, rpc: function(url, params, options) { - params.session_id = this.session_id; return this._super(url, params, options); }, /** @@ -58,7 +57,7 @@ instance.web.Session = instance.web.JsonRPC.extend( /** @lends instance.web.Sess session_init: function () { var self = this; // TODO: session store in cookie should be optional - this.session_id = this.get_cookie('sid'); + this.session_id = this.get_cookie('session_id'); return this.session_reload().then(function(result) { var modules = instance._modules.join(','); var deferred = self.rpc('/web/webclient/qweblist', {mods: modules}).then(self.load_qweb.bind(self)); -- cgit v1.2.3 From 9aaf79ffd2f80e797481cf5bed9cba35dbea9625 Mon Sep 17 00:00:00 2001 From: niv-openerp Date: Thu, 11 Jul 2013 15:23:01 +0200 Subject: more and more cleaning bzr revid: nicolas.vanhoren@openerp.com-20130711132301-5fl5giqio4n9yzgk --- addons/web/static/src/js/corelib.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/corelib.js b/addons/web/static/src/js/corelib.js index 01ff92c88a0..007a0adc803 100644 --- a/addons/web/static/src/js/corelib.js +++ b/addons/web/static/src/js/corelib.js @@ -1000,8 +1000,6 @@ instance.web.JsonRPC = instance.web.Class.extend(instance.web.PropertiesMixin, { context: this.user_context || {} }); // Construct a JSON-RPC2 request, method is currently unused - if (this.debug) - params.debug = 1; var payload = { jsonrpc: '2.0', method: 'call', @@ -1011,7 +1009,8 @@ instance.web.JsonRPC = instance.web.Class.extend(instance.web.PropertiesMixin, { var deferred = $.Deferred(); if (! options.shadow) this.trigger('request', url, payload); - + payload.debug = this.debug ? true : false; + this.rpc_function(url, payload).then( function (response, textStatus, jqXHR) { if (! options.shadow) -- cgit v1.2.3 From a7ab235c3a88dc817d61c526b9474c5537d5ed61 Mon Sep 17 00:00:00 2001 From: niv-openerp Date: Fri, 12 Jul 2013 11:53:09 +0200 Subject: changed session handling bzr revid: nicolas.vanhoren@openerp.com-20130712095309-41u7fi7ecs0y1lm1 --- addons/web/static/src/js/corelib.js | 17 ++++++++++------- addons/web/static/src/js/coresetup.js | 25 +++++++++++++++++-------- addons/web/static/src/xml/base.xml | 8 ++++---- 3 files changed, 31 insertions(+), 19 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/corelib.js b/addons/web/static/src/js/corelib.js index 007a0adc803..3b328fb8765 100644 --- a/addons/web/static/src/js/corelib.js +++ b/addons/web/static/src/js/corelib.js @@ -967,6 +967,8 @@ instance.web.JsonRPC = instance.web.Class.extend(instance.web.PropertiesMixin, { instance.web.PropertiesMixin.init.call(this); this.server = null; this.debug = ($.deparam($.param.querystring()).debug != undefined); + this.override_session = false; + this.session_id = undefined; }, setup: function(origin) { var window_origin = location.protocol+"//"+location.host, self=this; @@ -1009,7 +1011,6 @@ instance.web.JsonRPC = instance.web.Class.extend(instance.web.PropertiesMixin, { var deferred = $.Deferred(); if (! options.shadow) this.trigger('request', url, payload); - payload.debug = this.debug ? true : false; this.rpc_function(url, payload).then( function (response, textStatus, jqXHR) { @@ -1055,7 +1056,10 @@ instance.web.JsonRPC = instance.web.Class.extend(instance.web.PropertiesMixin, { dataType: 'json', contentType: 'application/json', data: JSON.stringify(payload), - processData: false + processData: false, + headers: { + "X-Openerp-Session-Id": this.override_session ? this.session_id : undefined, + }, }, url); if (this.synch) ajax.async = false; @@ -1134,11 +1138,10 @@ instance.web.JsonRPC = instance.web.Class.extend(instance.web.PropertiesMixin, { }, url: function(path, params) { - var qs = ''; - if (!_.isNull(params)) { - params = _.extend(params || {}, {session_id: this.session_id}); - qs = '?' + $.param(params); - } + params = _.extend(params || {}); + if (this.override_session) + params.session_id = this.session_id; + var qs = '?' + $.param(params); var prefix = _.any(['http://', 'https://', '//'], _.bind(_.str.startsWith, null, path)) ? '' : this.prefix; return prefix + path + qs; }, diff --git a/addons/web/static/src/js/coresetup.js b/addons/web/static/src/js/coresetup.js index f153d3ad73a..3ba5855533f 100644 --- a/addons/web/static/src/js/coresetup.js +++ b/addons/web/static/src/js/coresetup.js @@ -38,11 +38,10 @@ instance.web.Session = instance.web.JsonRPC.extend( /** @lends instance.web.Sess var self = this; this.setup(origin); instance.web.qweb.default_dict['_s'] = this.origin; - this.session_id = false; - this.uid = false; - this.username = false; + this.uid = null; + this.username = null; this.user_context= {}; - this.db = false; + this.db = null; this.module_list = instance._modules.slice(); this.module_loaded = {}; _(this.module_list).each(function (mod) { @@ -56,8 +55,6 @@ instance.web.Session = instance.web.JsonRPC.extend( /** @lends instance.web.Sess */ session_init: function () { var self = this; - // TODO: session store in cookie should be optional - this.session_id = this.get_cookie('session_id'); return this.session_reload().then(function(result) { var modules = instance._modules.join(','); var deferred = self.rpc('/web/webclient/qweblist', {mods: modules}).then(self.load_qweb.bind(self)); @@ -80,7 +77,19 @@ instance.web.Session = instance.web.JsonRPC.extend( /** @lends instance.web.Sess */ session_reload: function () { var self = this; - return this.rpc("/web/session/get_session_info", {}).done(function(result) { + var def = $.when(); + if (this.override_session) { + if (! this.session_id) { + def = this.rpc("/gen_session_id", {}).then(function(result) { + self.session_id = result; + }); + } + } else { + this.session_id = this.get_cookie('session_id'); + } + return def.then(function() { + return self.rpc("/web/session/get_session_info", {}) + }).then(function(result) { // If immediately follows a login (triggered by trying to restore // an invalid session or no session at all), refresh session data // (should not change, but just in case...) @@ -326,7 +335,7 @@ instance.web.Session = instance.web.JsonRPC.extend( /** @lends instance.web.Sess } _(_.extend({}, options.data || {}, - {session_id: this.session_id, token: token})) + {session_id: this.override_session ? this.session_id : undefined, token: token})) .each(function (value, key) { var $input = $form.find('[name=' + key +']'); if (!$input.length) { diff --git a/addons/web/static/src/xml/base.xml b/addons/web/static/src/xml/base.xml index a459486bf05..643bca0e798 100644 --- a/addons/web/static/src/xml/base.xml +++ b/addons/web/static/src/xml/base.xml @@ -654,7 +654,7 @@ /web/binary/upload_attachment - + Add... @@ -1320,7 +1320,7 @@
- + @@ -1372,7 +1372,7 @@ /web/binary/upload_attachment - +
@@ -1835,7 +1835,7 @@ - +

1. Import a .CSV file

Select a .CSV file to import. If you need a sample of file to import, you should use the export tool with the "Import Compatible" option. -- cgit v1.2.3