[MERGE] from 7.0
authorXavier Morel <xmo@openerp.com>
Wed, 13 Mar 2013 09:49:09 +0000 (10:49 +0100)
committerXavier Morel <xmo@openerp.com>
Wed, 13 Mar 2013 09:49:09 +0000 (10:49 +0100)
bzr revid: xmo@openerp.com-20130313094909-u21ee88l2lak9p2x

1  2 
addons/web/controllers/main.py
addons/web/http.py
addons/web/static/src/css/base.sass
addons/web/static/src/js/chrome.js
addons/web/static/src/js/corelib.js
addons/web/static/src/js/search.js
addons/web/static/src/js/view_form.js
addons/web/static/src/xml/base.xml

@@@ -91,16 -93,50 +93,50 @@@ def db_list(req)
      dbs = [i for i in dbs if re.match(r, i)]
      return dbs
  
- def db_monodb(req):
-     # if only one db exists, return it else return False
+ def db_monodb_redirect(req):
+     db = False
+     redirect = False
+     # 1 try the db in the url
+     db_url = req.params.get('db')
+     if db_url:
+         return (db_url, False)
      try:
          dbs = db_list(req)
-         if len(dbs) == 1:
-             return dbs[0]
 -    except xmlrpclib.Fault:
 +    except Exception:
          # ignore access denied
-         pass
-     return False
+         dbs = []
+     # 2 use the database from the cookie if it's listable and still listed
+     cookie_db = req.httprequest.cookies.get('last_used_database')
+     if cookie_db in dbs:
+         db = cookie_db
+     # 3 use the first db
+     if dbs and not db:
+         db = dbs[0]
+     # redirect to the chosen db if multiple are available
+     if db and len(dbs) > 1:
+         query = dict(urlparse.parse_qsl(req.httprequest.query_string, keep_blank_values=True))
+         query.update({ 'db': db })
+         redirect = req.httprequest.path + '?' + urllib.urlencode(query)
+     return (db, redirect)
+ def db_monodb(req):
+     # if only one db exists, return it else return False
+     return db_monodb_redirect(req)[0]
+ def redirect_with_hash(req, url, code=303):
+     if req.httprequest.user_agent.browser == 'msie':
+         try:
+             version = float(req.httprequest.user_agent.version)
+             if version < 10:
+                 return "<html><head><script>window.location = '%s#' + location.hash;</script></head></html>" % url
+         except Exception:
+             pass
+     return werkzeug.utils.redirect(url, code)
  
  def module_topological_sort(modules):
      """ Return a list of module names sorted so that their dependencies of the
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge