merge trunk

bzr revid: nicolas.vanhoren@openerp.com-20120814071632-jifvgwkj6lawrqo7
This commit is contained in:
niv-openerp 2012-08-14 09:16:32 +02:00
commit 3052a5fa1a
4 changed files with 23 additions and 18 deletions

View File

@ -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):

View File

@ -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)

View File

@ -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

View File

@ -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