Skip to content

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

Description

@smurf-U

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions