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

Route/HTTP middleware after method should execute after exception response generate #128

Open
smurf-U opened this issue Sep 21, 2022 · 0 comments

Comments

@smurf-U
Copy link

smurf-U commented Sep 21, 2022

Describe the bug

Trying to figure out how long it takes to process a route and if it is successful or not. By creating dispatch controller wrapper to calculate response time with status code and route info for example:

datas = []
def controller_wrapper(next_caller):
    route = {}
    def call(*args, **kw):
        try:
            route.update({'start': datetime.now(), 'name': request.route.url})
            print('Before handler!')
            return next_caller(*args, **kw)
        finally:
            print('After Handler!')
            route.update({'end':datetime.now(), 'status': response.get_status()})
            datas.append(route)
            print(":::::response", response.status_code, dir(response))

    return call
config.get_component('dispatch').register_controller_wrapper(controller_wrapper)

After Register above wrapper, and if one of controller gives exception then it will give status_code value as 200. Which is not accurate.

Expected behaviour

response.status_code should give 500 rather then None.

Version

turbogears2==2.4.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant