diff --git a/addons/web/controllers/main.py b/addons/web/controllers/main.py index 6d12f8a49fe..1d5cfabec2c 100644 --- a/addons/web/controllers/main.py +++ b/addons/web/controllers/main.py @@ -668,7 +668,7 @@ class WebClient(openerpweb.Controller): messages = ir_translation.search_read([('module','in',mods),('lang','=',lang), ('comments','like','openerp-web'),('value','!=',False), ('value','!=','')], - ['module','src','value','lang'], order='module') + ['module','src','value','lang'], order='module') for mod, msg_group in itertools.groupby(messages, key=operator.itemgetter('module')): translations_per_module.setdefault(mod,{'messages':[]}) translations_per_module[mod]['messages'].extend({'id': m['src'], @@ -797,9 +797,9 @@ class Session(openerpweb.Controller): return { "session_id": req.session_id, "uid": req.session._uid, - "context": req.session.get_context() if req.session._uid else {}, + "user_context": req.session.get_context() if req.session._uid else {}, "db": req.session._db, - "login": req.session._login, + "username": req.session._login, } @openerpweb.jsonrequest @@ -1072,7 +1072,7 @@ class DataSet(openerpweb.Controller): @openerpweb.jsonrequest def call(self, req, model, method, args, domain_id=None, context_id=None): return self._call_kw(req, model, method, args, {}) - + @openerpweb.jsonrequest def call_kw(self, req, model, method, args, kwargs): return self._call_kw(req, model, method, args, kwargs) @@ -1186,7 +1186,7 @@ class Binary(openerpweb.Controller): if width > 500: width = 500 if height > 500: height = 500 image_base64 = openerp.tools.image_resize_image(base64_source=image_base64, size=(width, height), encoding='base64', filetype='PNG') - + image_data = base64.b64decode(image_base64) except (TypeError, xmlrpclib.Fault): @@ -1468,7 +1468,7 @@ class Export(View): fields = self.fields_get(req, model) if ".id" in export_fields: fields['.id'] = fields.pop('id', {'string': 'ID'}) - + # To make fields retrieval more efficient, fetch all sub-fields of a # given field at the same time. Because the order in the export list is # arbitrary, this requires ordering all sub-fields of a given field diff --git a/addons/web/session.py b/addons/web/session.py index 54ccac79578..fa99f58afa8 100644 --- a/addons/web/session.py +++ b/addons/web/session.py @@ -22,7 +22,7 @@ class Service(object): def __init__(self, session, service_name): self.session = session self.service_name = service_name - + def __getattr__(self, method): def proxy_method(*args): result = self.session.send(self.service_name, method, *args) @@ -60,7 +60,7 @@ class OpenERPSession(object): in a web session. .. attribute:: context - + The session context, a ``dict``. Can be reloaded by calling :meth:`openerpweb.openerpweb.OpenERPSession.get_context` @@ -80,7 +80,7 @@ class OpenERPSession(object): self._suicide = False self.context = {} self.jsonp_requests = {} # FIXME use a LRU - + def send(self, service_name, method, *args): code_string = "warning -- %s\n\n%s" try: @@ -112,7 +112,7 @@ class OpenERPSession(object): def authenticate(self, db, login, password, env=None): uid = self.proxy('common').authenticate(db, login, password, env) self.bind(db, uid, login, password) - + if uid: self.get_context() return uid diff --git a/addons/web/static/src/js/corelib.js b/addons/web/static/src/js/corelib.js index f7a84e608c6..5bbd5316521 100644 --- a/addons/web/static/src/js/corelib.js +++ b/addons/web/static/src/js/corelib.js @@ -1,16 +1,16 @@ /* * Copyright (c) 2012, OpenERP S.A. * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * + * modification, are permitted provided that the following conditions are met: + * * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. + * list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * + * and/or other materials provided with the distribution. + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE @@ -243,7 +243,7 @@ instance.web.ParentedMixin = { /** * Backbone's events. Do not ever use it directly, use EventDispatcherMixin instead. - * + * * This class just handle the dispatching of events, it is not meant to be extended, * nor used directly. All integration with parenting and automatic unregistration of * events is done in EventDispatcherMixin. @@ -303,7 +303,7 @@ var Events = instance.web.Class.extend({ }); return lst; }, - + trigger : function(events) { var event, node, calls, tail, args, all, rest; if (!(calls = this._callbacks)) @@ -1043,7 +1043,7 @@ instance.web.JsonRPC = instance.web.Class.extend(instance.web.PropertiesMixin, { 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) { @@ -1054,7 +1054,7 @@ instance.web.JsonRPC = instance.web.Class.extend(instance.web.PropertiesMixin, { url.url = this.url(url.url, null); var ajax = _.extend({ type: "GET", - dataType: 'jsonp', + dataType: 'jsonp', jsonp: 'jsonp', cache: false, data: data diff --git a/addons/web/static/src/js/coresetup.js b/addons/web/static/src/js/coresetup.js index a8b0510389b..43d292b66db 100644 --- a/addons/web/static/src/js/coresetup.js +++ b/addons/web/static/src/js/coresetup.js @@ -49,7 +49,6 @@ instance.web.Session = instance.web.JsonRPC.extend( /** @lends instance.web.Sess _(this.module_list).each(function (mod) { self.module_loaded[mod] = true; }); - this.context = {}; this.active_id = null; return this.session_init(); }, @@ -67,7 +66,7 @@ instance.web.Session = instance.web.JsonRPC.extend( /** @lends instance.web.Sess return deferred.then(function() { return self.load_modules(); }); } return $.when( - deferred, + deferred, self.rpc('/web/webclient/bootstrap_translations', {mods: instance._modules}).then(function(trans) { instance.web._t.database.set_bundle(trans); }) @@ -86,13 +85,7 @@ instance.web.Session = instance.web.JsonRPC.extend( /** @lends instance.web.Sess // 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...) - _.extend(self, { - session_id: result.session_id, - db: result.db, - username: result.login, - uid: result.uid, - user_context: result.context - }); + _.extend(self, result); }); }, session_is_valid: function() { @@ -109,14 +102,7 @@ instance.web.Session = instance.web.JsonRPC.extend( /** @lends instance.web.Sess if (!result.uid) { return $.Deferred().reject(); } - - _.extend(self, { - session_id: result.session_id, - db: result.db, - username: result.login, - uid: result.uid, - user_context: result.context - }); + _.extend(self, result); if (!_volatile) { self.set_cookie('session_id', self.session_id); }