[MERGE] manual forward port of changes made in http dispatching in saas-2 branch since last web revid 3865 dle@openerp.com-20131023113414-mlwppd4d7vyh1tyj
bzr revid: chs@openerp.com-20131125165804-0d25q1vn5z0y9nv8
This commit is contained in:
parent
9f52ab382b
commit
28581cc734
|
@ -52,7 +52,6 @@ class ModelsConverter(werkzeug.routing.BaseConverter):
|
||||||
|
|
||||||
class ir_http(osv.AbstractModel):
|
class ir_http(osv.AbstractModel):
|
||||||
_name = 'ir.http'
|
_name = 'ir.http'
|
||||||
|
|
||||||
_description = "HTTP routing"
|
_description = "HTTP routing"
|
||||||
|
|
||||||
def _get_converters(self):
|
def _get_converters(self):
|
||||||
|
@ -83,9 +82,8 @@ class ir_http(osv.AbstractModel):
|
||||||
# what if error in security.check()
|
# what if error in security.check()
|
||||||
# -> res_users.check()
|
# -> res_users.check()
|
||||||
# -> res_users.check_credentials()
|
# -> res_users.check_credentials()
|
||||||
except http.SessionExpiredException:
|
except Exception:
|
||||||
request.session.logout()
|
request.session.logout()
|
||||||
raise http.SessionExpiredException("Session expired for request %s" % request.httprequest)
|
|
||||||
getattr(self, "_auth_method_%s" % auth_method)()
|
getattr(self, "_auth_method_%s" % auth_method)()
|
||||||
return auth_method
|
return auth_method
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,7 @@ import urlparse
|
||||||
import warnings
|
import warnings
|
||||||
|
|
||||||
import babel.core
|
import babel.core
|
||||||
|
import psycopg2
|
||||||
import simplejson
|
import simplejson
|
||||||
import werkzeug.contrib.sessions
|
import werkzeug.contrib.sessions
|
||||||
import werkzeug.datastructures
|
import werkzeug.datastructures
|
||||||
|
@ -920,11 +921,9 @@ class Root(object):
|
||||||
return explicit_session
|
return explicit_session
|
||||||
|
|
||||||
def setup_db(self, httprequest):
|
def setup_db(self, httprequest):
|
||||||
# if no db is found on the session try to deduce it from the domain
|
if not httprequest.session.db:
|
||||||
db = db_monodb(httprequest)
|
# allow "admin" routes to works without being logged in when in monodb.
|
||||||
if db != httprequest.session.db:
|
httprequest.session.db = db_monodb(httprequest)
|
||||||
httprequest.session.logout()
|
|
||||||
httprequest.session.db = db
|
|
||||||
|
|
||||||
def setup_lang(self, httprequest):
|
def setup_lang(self, httprequest):
|
||||||
if not "lang" in httprequest.session.context:
|
if not "lang" in httprequest.session.context:
|
||||||
|
@ -975,17 +974,29 @@ class Root(object):
|
||||||
|
|
||||||
request = self.get_request(httprequest)
|
request = self.get_request(httprequest)
|
||||||
|
|
||||||
|
def _dispatch_nodb():
|
||||||
|
func, arguments = self.nodb_routing_map.bind_to_environ(request.httprequest.environ).match()
|
||||||
|
request.set_handler(func, arguments, "none")
|
||||||
|
result = request.dispatch()
|
||||||
|
return result
|
||||||
|
|
||||||
with set_request(request):
|
with set_request(request):
|
||||||
db = request.session.db
|
db = request.session.db
|
||||||
if db:
|
if db:
|
||||||
openerp.modules.registry.RegistryManager.check_registry_signaling(db)
|
openerp.modules.registry.RegistryManager.check_registry_signaling(db)
|
||||||
result = request.registry['ir.http']._dispatch()
|
try:
|
||||||
|
ir_http = request.registry['ir.http']
|
||||||
|
except psycopg2.OperationalError:
|
||||||
|
# psycopg2 error. At this point, that's mean the database does not exists
|
||||||
|
# anymore. We unlog the user and failback in nodb mode
|
||||||
|
request.session.logout()
|
||||||
|
result = _dispatch_nodb()
|
||||||
|
else:
|
||||||
|
result = ir_http._dispatch()
|
||||||
openerp.modules.registry.RegistryManager.signal_caches_change(db)
|
openerp.modules.registry.RegistryManager.signal_caches_change(db)
|
||||||
else:
|
else:
|
||||||
# fallback to non-db handlers
|
result = _dispatch_nodb()
|
||||||
func, arguments = self.nodb_routing_map.bind_to_environ(request.httprequest.environ).match()
|
|
||||||
request.set_handler(func, arguments, "none")
|
|
||||||
result = request.dispatch()
|
|
||||||
response = self.get_response(httprequest, result, explicit_session)
|
response = self.get_response(httprequest, result, explicit_session)
|
||||||
return response(environ, start_response)
|
return response(environ, start_response)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue