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:
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?
@mod_auth.route(‘/admin’)
@admin.require(http_exception=403)
def admin():
return render_template('auth/admin.html')
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?
请先登录再写评论。
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()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?