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 # 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 # 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 # 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) in_store = session_store.get(sid)
for k, v in request.session.iteritems(): for k, v in request.session.iteritems():
stored = in_store.get(k) stored = in_store.get(k)
@ -426,13 +426,18 @@ class DisableCacheMiddleware(object):
referer = environ.get('HTTP_REFERER', '') referer = environ.get('HTTP_REFERER', '')
parsed = urlparse.urlparse(referer) parsed = urlparse.urlparse(referer)
debug = parsed.query.count('debug') >= 1 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 debug:
if 'Expires' in nh: del nh['Expires'] new_headers = [('Cache-Control', 'no-cache')]
if 'Etag' in nh: del nh['Etag'] unwanted_keys += ['Expires', 'Etag', 'Cache-Control']
nh['Cache-Control'] = 'no-cache'
start_response(status, nh.items()) 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) return self.app(environ, start_wrapped)
class Root(object): class Root(object):

View File

@ -164,8 +164,7 @@ def module_installed_bypass_session(dbname):
try: try:
import openerp.modules.registry import openerp.modules.registry
registry = openerp.modules.registry.RegistryManager.get(dbname) registry = openerp.modules.registry.RegistryManager.get(dbname)
cr = registry.db.cursor() with registry.cursor() as cr:
try:
m = registry.get('ir.module.module') m = registry.get('ir.module.module')
# TODO The following code should move to ir.module.module.list_installed_modules() # TODO The following code should move to ir.module.module.list_installed_modules()
domain = [('state','=','installed'), ('name','in', loadable)] 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']) deps_read = registry.get('ir.module.module.dependency').read(cr, 1, deps, ['name'])
dependencies = [i['name'] for i in deps_read] dependencies = [i['name'] for i in deps_read]
modules[module['name']] = dependencies modules[module['name']] = dependencies
finally:
cr.close()
except Exception,e: except Exception,e:
pass pass
sorted_modules = module_topological_sort(modules) 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='/'): def login_and_redirect(req, db, login, key, redirect_url='/'):
req.session.authenticate(db, login, key, {}) req.session.authenticate(db, login, key, {})
redirect = werkzeug.utils.redirect(redirect_url, 303) redirect = werkzeug.utils.redirect(redirect_url, 303)
redirect.autocorrect_location_header = False
cookie_val = urllib2.quote(simplejson.dumps(req.session_id)) cookie_val = urllib2.quote(simplejson.dumps(req.session_id))
redirect.set_cookie('instance0|session_id', cookie_val) redirect.set_cookie('instance0|session_id', cookie_val)
return redirect return redirect
@ -1359,19 +1357,19 @@ class Binary(openerpweb.Controller):
headers = [('Content-Type', 'image/png')] headers = [('Content-Type', 'image/png')]
etag = req.httprequest.headers.get('If-None-Match') etag = req.httprequest.headers.get('If-None-Match')
hashed_session = hashlib.md5(req.session_id).hexdigest() 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 etag:
if not id and hashed_session == etag: if not id and hashed_session == etag:
return werkzeug.wrappers.Response(status=304) return werkzeug.wrappers.Response(status=304)
else: 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: if hashlib.md5(date).hexdigest() == etag:
return werkzeug.wrappers.Response(status=304) return werkzeug.wrappers.Response(status=304)
retag = hashed_session retag = hashed_session
try: try:
id = None if not id else simplejson.loads(id)
if type(id) is list:
id = id[0] # m2o
if not id: if not id:
res = Model.default_get([field], context).get(field) res = Model.default_get([field], context).get(field)
image_data = base64.b64decode(res) image_data = base64.b64decode(res)

View File

@ -66,9 +66,9 @@ instance.web.Dialog = instance.web.Widget.extend({
max_width: '95%', max_width: '95%',
height: 'auto', height: 'auto',
min_height: 0, min_height: 0,
max_height: this.get_height('100%') - 140, max_height: this.get_height('100%') - 200,
autoOpen: false, autoOpen: false,
position: [false, 50], position: [false, 40],
buttons: {}, buttons: {},
beforeClose: function () { self.on_close(); }, beforeClose: function () { self.on_close(); },
resizeStop: this.on_resized resizeStop: this.on_resized

View File

@ -16,4 +16,6 @@ class Mobile(openerpweb.Controller):
@openerpweb.httprequest @openerpweb.httprequest
def index(self, req): 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