Merge lp:~openerp-dev/openerp-web/7.0-monodb-again-fme into lp:openerp-web/7.0

Proposed by Christophe Simonis (OpenERP)
Status: Rejected
Rejected by: Xavier (Open ERP)
Proposed branch: lp:~openerp-dev/openerp-web/7.0-monodb-again-fme
Merge into: lp:openerp-web/7.0
Diff against target: 112 lines (+14/-35)
2 files modified
addons/web/controllers/main.py (+13/-28)
addons/web/static/src/js/chrome.js (+1/-7)
To merge this branch: bzr merge lp:~openerp-dev/openerp-web/7.0-monodb-again-fme
Reviewer Review Type Date Requested Status
Xavier (Open ERP) (community) Needs Information
Review via email: mp+159115@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Xavier (Open ERP) (xmo-deactivatedaccount) wrote :

Why?

review: Needs Information

Unmerged revisions

3853. By Fabien Meghazi (OpenERP)

[IMP] Hard code instance._selected_db in template

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'addons/web/controllers/main.py'
2--- addons/web/controllers/main.py 2013-04-05 13:47:47 +0000
3+++ addons/web/controllers/main.py 2013-04-16 09:52:29 +0000
4@@ -93,14 +93,8 @@
5 dbs = [i for i in dbs if re.match(r, i)]
6 return dbs
7
8-def db_monodb_redirect(req):
9+def db_monodb(req):
10 db = False
11- redirect = False
12-
13- # 1 try the db in the url
14- db_url = req.params.get('db')
15- if db_url:
16- return (db_url, False)
17
18 try:
19 dbs = db_list(req)
20@@ -108,25 +102,18 @@
21 # ignore access denied
22 dbs = []
23
24- # 2 use the database from the cookie if it's listable and still listed
25- cookie_db = req.httprequest.cookies.get('last_used_database')
26- if cookie_db in dbs:
27- db = cookie_db
28-
29- # 3 use the first db
30- if dbs and not db:
31+ # 1 try the db in the url
32+ db = req.params.get('db')
33+
34+ # 2 try the db in the cookie
35+ if not db:
36+ db = req.httprequest.cookies.get('last_used_database')
37+
38+ # 3 use the first db, ensure db is listed
39+ if dbs and db not in dbs:
40 db = dbs[0]
41
42- # redirect to the chosen db if multiple are available
43- if db and len(dbs) > 1:
44- query = dict(urlparse.parse_qsl(req.httprequest.query_string, keep_blank_values=True))
45- query.update({ 'db': db })
46- redirect = req.httprequest.path + '?' + urllib.urlencode(query)
47- return (db, redirect)
48-
49-def db_monodb(req):
50- # if only one db exists, return it else return False
51- return db_monodb_redirect(req)[0]
52+ return db
53
54 def redirect_with_hash(req, url, code=303):
55 if req.httprequest.user_agent.browser == 'msie':
56@@ -551,6 +538,7 @@
57 <script type="text/javascript">
58 $(function() {
59 var s = new openerp.init(%(modules)s);
60+ s._selected_db = %(db)s;
61 %(init)s
62 });
63 </script>
64@@ -569,14 +557,11 @@
65
66 @openerpweb.httprequest
67 def index(self, req, s_action=None, db=None, **kw):
68- db, redir = db_monodb_redirect(req)
69- if redir:
70- return redirect_with_hash(req, redir)
71-
72 js = "\n ".join('<script type="text/javascript" src="%s"></script>' % i for i in manifest_list(req, 'js', db=db))
73 css = "\n ".join('<link rel="stylesheet" href="%s">' % i for i in manifest_list(req, 'css', db=db))
74
75 r = html_template % {
76+ 'db': simplejson.dumps(db_monodb(req)),
77 'js': js,
78 'css': css,
79 'modules': simplejson.dumps(module_boot(req, db=db)),
80
81=== modified file 'addons/web/static/src/js/chrome.js'
82--- addons/web/static/src/js/chrome.js 2013-03-19 15:43:45 +0000
83+++ addons/web/static/src/js/chrome.js 2013-04-16 09:52:29 +0000
84@@ -603,7 +603,7 @@
85 this._super(parent);
86 this.has_local_storage = typeof(localStorage) != 'undefined';
87 this.db_list = null;
88- this.selected_db = null;
89+ this.selected_db = instance._selected_db;
90 this.selected_login = null;
91 this.params = action.params || {};
92 if (_.isEmpty(this.params)) {
93@@ -614,9 +614,6 @@
94 } else if ($.deparam.querystring().db) {
95 this.params.db = $.deparam.querystring().db;
96 }
97- if (this.params.db) {
98- this.selected_db = this.params.db;
99- }
100
101 if (this.params.login_successful) {
102 this.on('login_successful', this, this.params.login_successful);
103@@ -674,9 +671,6 @@
104 on_db_loaded: function (result) {
105 var self = this;
106 this.db_list = result;
107- if (!this.selected_db) {
108- this.selected_db = result[0];
109- }
110 this.$("[name=db]").replaceWith(QWeb.render('Login.dblist', { db_list: this.db_list, selected_db: this.selected_db}));
111 if(this.db_list.length === 0) {
112 this.do_action("database_manager");