diff --git a/addons/web/__openerp__.py b/addons/web/__openerp__.py
index 74f4cdac3f7..a8dda8bcada 100644
--- a/addons/web/__openerp__.py
+++ b/addons/web/__openerp__.py
@@ -52,7 +52,7 @@
"static/src/js/view_list.js",
"static/src/js/view_list_editable.js",
"static/src/js/view_tree.js",
- "static/src/js/view_editor.js",
+ "static/src/js/view_editor.js"
],
'css' : [
"static/lib/jquery.superfish/css/superfish.css",
diff --git a/addons/web/common/http.py b/addons/web/common/http.py
index da34b8a654e..abdd8683d0f 100644
--- a/addons/web/common/http.py
+++ b/addons/web/common/http.py
@@ -2,7 +2,6 @@
#----------------------------------------------------------
# OpenERP Web HTTP layer
#----------------------------------------------------------
-import StringIO
import ast
import contextlib
import functools
@@ -88,12 +87,12 @@ class WebRequest(object):
self.httpresponse = None
self.httpsession = request.session
self.config = config
- self.session = None
def init(self, params):
self.params = dict(params)
+ # OpenERP session setup
self.session_id = self.params.pop("session_id", None) or uuid.uuid4().hex
- self.session = self.httpsession.setdefault(self.session_id, session.OpenERPSession(self.session_id))
+ self.session = self.httpsession.setdefault(self.session_id, session.OpenERPSession())
self.session.config = self.config
self.context = self.params.pop('context', None)
self.debug = self.params.pop('debug', False) != False
@@ -142,11 +141,10 @@ class JsonRequest(WebRequest):
method = self.httprequest.method
args = self.httprequest.args
jsonp = args.get('jsonp', False)
+ requestf = None
+ request = None
- if jsonp and args.get('r'):
- # jsonp method GET
- requestf = StringIO.StringIO(args.get('r'))
- elif jsonp and method == 'POST':
+ if jsonp and method == 'POST':
# jsonp 2 steps step1 POST: save call
self.init(args)
req.session.jsonp_requests[args.get('id')] = self.httprequest.form['r']
@@ -156,7 +154,10 @@ class JsonRequest(WebRequest):
elif args['jsonp'] and args.get('id'):
# jsonp 2 steps step2 GET: run and return result
self.init(args)
- requestf = StringIO.StringIO(self.session.jsonp_requests.pop(args.get(id), ""))
+ request = self.session.jsonp_requests.pop(args.get(id), "")
+ elif jsonp and args.get('r'):
+ # jsonp method GET
+ request = args.get('r')
else:
# regular jsonrpc2
requestf = self.httprequest.stream
@@ -164,10 +165,15 @@ class JsonRequest(WebRequest):
response = {"jsonrpc": "2.0" }
error = None
try:
- self.jsonrequest = simplejson.loads(direct_json_request, object_hook=nonliterals.non_literal_decoder)
+ # Read POST content or POST Form Data named "request"
+ if requestf:
+ self.jsonrequest = simplejson.load(requestf, object_hook=nonliterals.non_literal_decoder)
+ else:
+ self.jsonrequest = simplejson.loads(request, object_hook=nonliterals.non_literal_decoder)
self.init(self.jsonrequest.get("params", {}))
if _logger.isEnabledFor(logging.DEBUG):
- _logger.debug("[%s] --> %s.%s\n%s", rid, controller.__class__.__name__, method.__name__, pprint.pformat(self.jsonrequest))
+ _logger.debug("--> %s.%s\n%s", controller.__class__.__name__, method.__name__, pprint.pformat(self.jsonrequest))
+ response['id'] = self.jsonrequest.get('id')
response["result"] = method(controller, self, **self.params)
except openerplib.AuthenticationError:
error = {
@@ -376,21 +382,6 @@ class ControllerType(type):
class Controller(object):
__metaclass__ = ControllerType
-class Proxy(Controller):
- _cp_path = '/web/proxy'
-
- @jsonrequest
- def load(self, req, path):
- #req.config.socket_port
- #if not re.match('^/[^/]+/static/.*', path):
- # return werkzeug.exceptions.BadRequest()
-
- env = req.httprequest.environ
- port = env['SERVER_PORT']
-
- o = urllib.urlopen('http://127.0.0.1:%s%s' % (port, path))
- return o.read()
-
class Root(object):
"""Root WSGI application for the OpenERP Web Client.
diff --git a/addons/web/common/session.py b/addons/web/common/session.py
index 6947789a7b5..be1a2b749da 100644
--- a/addons/web/common/session.py
+++ b/addons/web/common/session.py
@@ -28,8 +28,7 @@ class OpenERPSession(object):
Used to store references to non-literal domains which need to be
round-tripped to the client browser.
"""
- def __init__(self, sid):
- self.id = sid
+ def __init__(self):
self.config = None
self._db = False
self._uid = False
diff --git a/addons/web/controllers/main.py b/addons/web/controllers/main.py
index 81061ba5477..c286819ab86 100644
--- a/addons/web/controllers/main.py
+++ b/addons/web/controllers/main.py
@@ -242,6 +242,21 @@ class WebClient(openerpweb.Controller):
"version": web.common.release.version
}
+class Proxy(openerpweb.Controller):
+ _cp_path = '/web/proxy'
+
+ @jsonrequest
+ def load(self, req, path):
+ #req.config.socket_port
+ #if not re.match('^/[^/]+/static/.*', path):
+ # return werkzeug.exceptions.BadRequest()
+
+ env = req.httprequest.environ
+ port = env['SERVER_PORT']
+
+ o = urllib.urlopen('http://127.0.0.1:%s%s' % (port, path))
+ return o.read()
+
class Database(openerpweb.Controller):
_cp_path = "/web/database"
diff --git a/addons/web/static/src/js/core.js b/addons/web/static/src/js/core.js
index e1591f46235..1f5e29a311a 100644
--- a/addons/web/static/src/js/core.js
+++ b/addons/web/static/src/js/core.js
@@ -362,7 +362,6 @@ openerp.web.Connection = openerp.web.CallbackEnabled.extend( /** @lends openerp.
// be saved to (and revived from) cookies
this.name = openerp._session_id;
},
-
bind: function(server, continuation) {
if(_.isFunction(server)) {
@@ -390,37 +389,12 @@ openerp.web.Connection = openerp.web.CallbackEnabled.extend( /** @lends openerp.
this.active_id = null;
this.do_load_qweb(['/web/webclient/qweb'], continuation);
},
-
connect: function(server, db, login, password, continuation) {
var self = this;
this.bind(server, function() {
self.login(db, login, password, continuation);
});
},
-
- get_absolute_url: function(path) {
- var absolute_url,
- r_has_protocol = /^https?:\/\//,
- r_absolute_internal = /^\/[^\/]/; // starts with / (but not //)
-
-
- if (r_has_protocol.test(path)) {
- if (!_.str.startsWith(path, this.server + '/')) {
- $.error('can only contact openerp.server');
- }
- absolute_url = path;
- } else if (r_absolute_internal.test(path)) {
- absolute_url = this.server + path;
- } else { // relative url
- // XXX is it correct to mix document.location and this.server ??
- var parts = document.location.pathname.split('/');
- parts.pop();
- parts.push(path);
- absolute_url = this.server + parts.join('/');
- }
- return absolute_url;
- },
-
/**
* Executes an RPC call, registering the provided callbacks.
*
@@ -454,7 +428,6 @@ openerp.web.Connection = openerp.web.CallbackEnabled.extend( /** @lends openerp.
});
}).then(success_callback, error_callback).promise();
},
-
/**
* Raw JSON-RPC call
*
@@ -521,7 +494,7 @@ openerp.web.Connection = openerp.web.CallbackEnabled.extend( /** @lends openerp.
* The session is validated either by login or by restoration of a previous session
*/
on_session_valid: function(continuation) {
- this.load_modules(continuation);
+ this.load_modules().then(function() { continuation() } );
},
on_session_invalid: function(continuation) {
},
@@ -547,7 +520,9 @@ openerp.web.Connection = openerp.web.CallbackEnabled.extend( /** @lends openerp.
//}).done(success_callback);
});
},
- login: function() { this.session_authenticate.apply(this, arguments); },
+ login: function() {
+ this.session_authenticate.apply(this, arguments);
+ },
/**
* Reloads uid and session_id from local storage, if they exist
*/
@@ -628,17 +603,12 @@ openerp.web.Connection = openerp.web.CallbackEnabled.extend( /** @lends openerp.
},
/**
* Load additional web addons of that instance and init them
- * FIXME do all actions in sync...
*/
- load_modules: function(continuation) {
+ load_modules: function() {
var self = this;
-
- this.module_loading.done(continuation);
- //if (this.module_loading.state() !== "pending") {
- if (this.module_loading.isResolved() || this.module_loading.isRejected()) {
- return;
+ if(openerp._modules_loaded) {
+ return $.when();
}
-
this.rpc('/web/session/modules', {}, function(result) {
self.module_list = result;
var lang = self.user_context.lang;
@@ -649,37 +619,17 @@ openerp.web.Connection = openerp.web.CallbackEnabled.extend( /** @lends openerp.
var file_list = ["/web/static/lib/datejs/globalization/" +
self.user_context.lang.replace("_", "-") + ".js"
];
-
- /*
- self.rpc('/web/webclient/qweblist', {mods: modules}, self.do_load_qweb);
- self.rpc('/web/webclient/csslist', {mods: modules}, self.do_load_css);
- self.rpc('/web/webclient/jslist', {mods: modules}, function(files) {
- self.do_load_js(file_list.concat(files));
- });
- openerp._modules_loaded = true;
- // */
-
- self.rpc('/web/webclient/qweblist', {mods: modules}, function(files) {
- self.do_load_qweb(files, function() {
- // once qweb files are loaded...
- self.rpc('/web/webclient/csslist', {mods: modules}, function(files) {
- self.do_load_css(files, function() {
- // once css files are loaded
- self.rpc('/web/webclient/jslist', {mods: modules}, function(files) {
- self.do_load_js(file_list.concat(files), function() {
- self.on_modules_loaded();
- self.module_loading.resolve();
- });
- });
- });
- });
- });
- });
-
+ return $.when(
+ self.rpc('/web/webclient/qweblist', {mods: modules}, self.do_load_qweb),
+ self.rpc('/web/webclient/csslist', {mods: modules}, self.do_load_css),
+ self.rpc('/web/webclient/jslist', {mods: modules}, function(files) {
+ self.do_load_js(file_list.concat(files));
+ })
+ );
});
});
},
- do_load_css: function (files, callback) {
+ do_load_css: function (files) {
var self = this;
_.each(files, function (file) {
$('head').append($('', {
@@ -688,9 +638,8 @@ openerp.web.Connection = openerp.web.CallbackEnabled.extend( /** @lends openerp.
'type': 'text/css'
}));
});
- if (callback) { callback(); }
},
- do_load_js: function(files, callback) {
+ do_load_js: function(files) {
var self = this;
if(files.length != 0) {
var file = files.shift();
@@ -706,21 +655,18 @@ openerp.web.Connection = openerp.web.CallbackEnabled.extend( /** @lends openerp.
var head = document.head || document.getElementsByTagName('head')[0];
head.appendChild(tag);
} else {
- if (callback) { callback(); }
+ self.on_modules_loaded();
}
},
- do_load_qweb: function(files, callback) {
+ do_load_qweb: function(files) {
var self = this;
-
if (files.length != 0) {
var file = files.shift();
- self.rpc('/web/jsonp/static_proxy', {path: file}, function(xml) {
+ self.rpc('/web/proxy/load', {path: file}, function(xml) {
openerp.web.qweb.add_template(_.str.trim(xml));
self.do_load_qweb(files, callback);
});
- } else {
- if (callback) { callback(); }
- }
+ }
},
on_modules_loaded: function() {
for(var j=0; j';
@@ -1181,6 +1128,7 @@ openerp.web.qweb.format_text_node = function(s) {
openerp.connection = new openerp.web.Connection();
openerp.web.qweb.default_dict['__debug__'] = openerp.connection.debug;
+/** Jquery extentions */
$.Mutex = (function() {
function Mutex() {
this.def = $.Deferred().resolve();