Possible to step into decorated functions?

I'm working on a Flask project and am using Flask-Principal.  One way to apply access checks is to use a decorator like:

@mod_auth.route(‘/admin’)
@admin.require(http_exception=403)
def admin():
    return render_template('auth/admin.html')
prettyPrint();
How does one debug the decorator?  I've tried step in and force step in, but it doesn't seem to work.

Is there a way to step into the decorator?
1 comment
Comment actions Permalink
from functools import wraps

def decorator_generator(param):
    # let's say this is in some library far off, and heavily used. putting a breakpoint
    # on the print statement would yield 100's of debugs before the one you really one to
    # get into debugging... Setting a breakpoint here is useless.
    def decorator(func):
        @wraps(func)
        def wrapper(*params, **vars):
            print param
            func(*params, **vars)

        return wrapper

    return decorator


def debug_decorator(func):
    @wraps(func)
    def wrapper(*params, **vars):
        # set your breakpoint here (ctrl-f8)
        # step into the function (f7) to step into the decorator you want to debug
        func(*params, **vars)

    return wrapper


# add the debug decorator_generator's before the decorator you want to debug 
@debug_decorator
@decorator_generator('decorated')
def foo():
    return 'bar'


if __name__ == '__main__':
    foo()
prettyPrint();

The code could be improved if we can throw a breakpoint in the debbuger, but i couldn't find a way to do that.

@jetbrains, is there any way to ask for the debugger to intercept?
0

Please sign in to leave a comment.