Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[14.0][FIX]TypeError: 'EndPoint' object is not iterable. #6

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 36 additions & 3 deletions odoo_elasticapm/ir_http.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,38 @@

SKIP_PATH = ["/connector/runjob", "/longpolling/", "/web_editor"]

def base_dispatch(cls):
cls._handle_debug()

ori_dispatch = IrHttp._dispatch
# locate the controller method
try:
rule, arguments = cls._match(request.httprequest.path)
func = rule.endpoint
except werkzeug.exceptions.NotFound as e:
return cls._handle_exception(e)

# check authentication level
try:
auth_method = cls._authenticate(func)
except Exception as e:
return cls._handle_exception(e)

processing = cls._postprocess_args(arguments, rule)
if processing:
return processing

# set and execute handler
try:
request.set_handler(func, arguments, auth_method)
result = request.dispatch()
if isinstance(result, Exception):
raise result
except Exception as e:
return cls._handle_exception(e)

return result

ori_dispatch = base_dispatch


def skip_tracing():
Expand All @@ -32,11 +62,13 @@ def skip_tracing():


def before_dispatch():
print("\n\n\n Called in before_dispatch \n\n\n")
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
print("\n\n\n Called in before_dispatch \n\n\n")

elastic_apm_client.begin_transaction("request")
elasticapm.set_user_context(user_id=request.session.uid)


def after_dispatch(response):
print("\n\n\n Called in after_dispatch \n\n\n")
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
print("\n\n\n Called in after_dispatch \n\n\n")

path_info = request.httprequest.environ.get("PATH_INFO")
name = path_info
for key in ["model", "method", "signal"]:
Expand Down Expand Up @@ -71,12 +103,13 @@ def _dispatch(self):
@classmethod
def _dispatch(cls):
if skip_tracing():
return ori_dispatch()
return ori_dispatch(cls)
else:
before_dispatch()
response = ori_dispatch()
response = ori_dispatch(cls)
after_dispatch(response)
return response


IrHttp._dispatch = _dispatch

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change