标签:style some rmi something required perm 入参 word mis
def decorator_a(func): print ‘Get in decorator_a‘ def inner_a(*args, **kwargs): print ‘Get in inner_a‘ return func(*args, **kwargs) return inner_a def decorator_b(func): print ‘Get in decorator_b‘ def inner_b(*args, **kwargs): print ‘Get in inner_b‘ return func(*args, **kwargs) return inner_b @decorator_b#f=decorator_b(f) @decorator_a#f=decorator_a(f) def f(x): print ‘Get in f‘ return x * 2
"""
Get in decorator_a
Get in decorator_b
"""
def decorator_a(func): print(‘Get in decorator_a‘) def inner_a(*args, **kwargs): print(‘Get in inner_a‘) return func(*args, **kwargs) return inner_a def decorator_b(func): print(‘Get in decorator_b‘) def inner_b(*args, **kwargs): print(‘Get in inner_b‘) return func(*args, **kwargs) return inner_b def f(x): print(‘Get in f‘) return x * 2 f=decorator_a(f) f=decorator_b(f)
"""
Get in decorator_a
Get in decorator_b
"""
def decorator_a(func): print(‘Get in decorator_a‘) def inner_a(*args, **kwargs): print(‘Get in inner_a‘) return func(*args, **kwargs) return inner_a def decorator_b(func): print(‘Get in decorator_b‘) def inner_b(*args, **kwargs): print(‘Get in inner_b‘) return func(*args, **kwargs) return inner_b @decorator_b#f=decorator_b(f) @decorator_a#f=decorator_a(f) def f(x): print(‘Get in f‘) return x * 2 f(1)
"""
Get in decorator_a
Get in decorator_b
Get in inner_b
Get in inner_a
Get in f
"""
实际应用过程中,先验证有没有登录,在验证权限够不够,采用从上到下的顺序来装饰函数
@login_required @permision_allowed def f() # Do something return
标签:style some rmi something required perm 入参 word mis
原文地址:https://www.cnblogs.com/z-x-y/p/9157238.html