mirror of
https://gitlab.com/flectra-hq/flectra.git
synced 2025-02-25 18:55:21 -06:00
[PATCH] upstream
This commit is contained in:
@@ -19,7 +19,7 @@ import flectra
|
||||
from flectra import api, models, registry, exceptions, tools, http
|
||||
from flectra.addons.base.models.ir_http import RequestUID, ModelConverter
|
||||
from flectra.addons.base.models.qweb import QWebException
|
||||
from flectra.http import request, HTTPRequest
|
||||
from flectra.http import request
|
||||
from flectra.osv import expression
|
||||
from flectra.tools import config, ustr, pycompat
|
||||
|
||||
@@ -519,10 +519,6 @@ class IrHttp(models.AbstractModel):
|
||||
|
||||
@classmethod
|
||||
def reroute(cls, path):
|
||||
if isinstance(path, str):
|
||||
path = path.encode("utf-8")
|
||||
path = path.decode("latin1", "replace")
|
||||
|
||||
if not hasattr(request, 'rerouting'):
|
||||
request.rerouting = [request.httprequest.path]
|
||||
if path in request.rerouting:
|
||||
@@ -530,8 +526,16 @@ class IrHttp(models.AbstractModel):
|
||||
request.rerouting.append(path)
|
||||
if len(request.rerouting) > cls.rerouting_limit:
|
||||
raise Exception("Rerouting limit exceeded")
|
||||
environ = dict(request.httprequest._HTTPRequest__environ, PATH_INFO=path)
|
||||
request.httprequest = HTTPRequest(environ)
|
||||
request.httprequest.environ['PATH_INFO'] = path
|
||||
# void werkzeug cached_property. TODO: find a proper way to do this
|
||||
for key in ('full_path', 'url', 'base_url'):
|
||||
request.httprequest.__dict__.pop(key, None)
|
||||
# since werkzeug 2.0 `path`` became an attribute and is not a cached property anymore
|
||||
if hasattr(type(request.httprequest), 'path'): # cached property
|
||||
request.httprequest.__dict__.pop('path', None)
|
||||
else: # direct attribute
|
||||
request.httprequest.path = '/' + path.lstrip('/')
|
||||
|
||||
return cls._dispatch()
|
||||
|
||||
@classmethod
|
||||
@@ -573,7 +577,7 @@ class IrHttp(models.AbstractModel):
|
||||
elif isinstance(exception, QWebException):
|
||||
values.update(qweb_exception=exception)
|
||||
|
||||
if isinstance(exception.error, exceptions.AccessError):
|
||||
if type(exception.error) == exceptions.AccessError:
|
||||
code = 403
|
||||
|
||||
elif isinstance(exception, werkzeug.exceptions.HTTPException):
|
||||
|
||||
Reference in New Issue
Block a user