diff --git a/addons/web/common/http.py b/addons/web/common/http.py index 6b1a28e5803..6c71e4696b5 100644 --- a/addons/web/common/http.py +++ b/addons/web/common/http.py @@ -382,7 +382,7 @@ def session_context(request, storage_path, session_cookie='sessionid'): # note that domains_store and contexts_store are append-only (we # only ever add items to them), so we can just update one with the # other to get the right result, if we want to merge the - # ``context`` dict we'll need something smarter + # ``context`` dict we'll need something smarter in_store = session_store.get(sid) for k, v in request.session.iteritems(): stored = in_store.get(k) @@ -426,13 +426,18 @@ class DisableCacheMiddleware(object): referer = environ.get('HTTP_REFERER', '') parsed = urlparse.urlparse(referer) debug = parsed.query.count('debug') >= 1 - nh = dict(headers) - if 'Last-Modified' in nh: del nh['Last-Modified'] + + new_headers = [] + unwanted_keys = ['Last-Modified'] if debug: - if 'Expires' in nh: del nh['Expires'] - if 'Etag' in nh: del nh['Etag'] - nh['Cache-Control'] = 'no-cache' - start_response(status, nh.items()) + new_headers = [('Cache-Control', 'no-cache')] + unwanted_keys += ['Expires', 'Etag', 'Cache-Control'] + + for k, v in headers: + if k not in unwanted_keys: + new_headers.append((k, v)) + + start_response(status, new_headers) return self.app(environ, start_wrapped) class Root(object): diff --git a/addons/web/controllers/main.py b/addons/web/controllers/main.py index 84317d8a4f7..ec356d89aa8 100644 --- a/addons/web/controllers/main.py +++ b/addons/web/controllers/main.py @@ -164,8 +164,7 @@ def module_installed_bypass_session(dbname): try: import openerp.modules.registry registry = openerp.modules.registry.RegistryManager.get(dbname) - cr = registry.db.cursor() - try: + with registry.cursor() as cr: m = registry.get('ir.module.module') # TODO The following code should move to ir.module.module.list_installed_modules() domain = [('state','=','installed'), ('name','in', loadable)] @@ -177,8 +176,6 @@ def module_installed_bypass_session(dbname): deps_read = registry.get('ir.module.module.dependency').read(cr, 1, deps, ['name']) dependencies = [i['name'] for i in deps_read] modules[module['name']] = dependencies - finally: - cr.close() except Exception,e: pass sorted_modules = module_topological_sort(modules) @@ -326,6 +323,7 @@ def make_conditional(req, response, last_modified=None, etag=None): def login_and_redirect(req, db, login, key, redirect_url='/'): req.session.authenticate(db, login, key, {}) redirect = werkzeug.utils.redirect(redirect_url, 303) + redirect.autocorrect_location_header = False cookie_val = urllib2.quote(simplejson.dumps(req.session_id)) redirect.set_cookie('instance0|session_id', cookie_val) return redirect @@ -1359,19 +1357,19 @@ class Binary(openerpweb.Controller): headers = [('Content-Type', 'image/png')] etag = req.httprequest.headers.get('If-None-Match') hashed_session = hashlib.md5(req.session_id).hexdigest() + id = None if not id else simplejson.loads(id) + if type(id) is list: + id = id[0] # m2o if etag: if not id and hashed_session == etag: return werkzeug.wrappers.Response(status=304) else: - date = Model.read([int(id)], [last_update], context)[0].get(last_update) + date = Model.read([id], [last_update], context)[0].get(last_update) if hashlib.md5(date).hexdigest() == etag: return werkzeug.wrappers.Response(status=304) retag = hashed_session try: - id = None if not id else simplejson.loads(id) - if type(id) is list: - id = id[0] # m2o if not id: res = Model.default_get([field], context).get(field) image_data = base64.b64decode(res) diff --git a/addons/web/static/src/js/chrome.js b/addons/web/static/src/js/chrome.js index 4b2e0751e8d..43747d8e3cf 100644 --- a/addons/web/static/src/js/chrome.js +++ b/addons/web/static/src/js/chrome.js @@ -66,9 +66,9 @@ instance.web.Dialog = instance.web.Widget.extend({ max_width: '95%', height: 'auto', min_height: 0, - max_height: this.get_height('100%') - 140, + max_height: this.get_height('100%') - 200, autoOpen: false, - position: [false, 50], + position: [false, 40], buttons: {}, beforeClose: function () { self.on_close(); }, resizeStop: this.on_resized diff --git a/addons/web_mobile/controllers.py b/addons/web_mobile/controllers.py index 225f78ee111..ae05056bdc3 100644 --- a/addons/web_mobile/controllers.py +++ b/addons/web_mobile/controllers.py @@ -16,4 +16,6 @@ class Mobile(openerpweb.Controller): @openerpweb.httprequest def index(self, req): - return werkzeug.utils.redirect('/web_mobile/static/src/web_mobile.html', 301) + r = werkzeug.utils.redirect('/web_mobile/static/src/web_mobile.html', 301) + r.autocorrect_location_header = False + return r