Detail: flask decorator issue (python)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
# Main view
@app.route('/', defaults={'page': app.config['INDEX_PAGE']}, methods=['GET', 'POST'])
@app.route('/<path:page>', methods=['GET', 'POST'])
@check_acl()
def view(page):

# ACL Decorator
def check_acl(page=None):
    def decorator(f):
        @wraps(f)
        def decorated(*args, **kwargs):
            print "Pasa por decorator"
            return f(*args, **kwargs)
        return decorated
    return decorator

# Issue: The only thing I've to know into the decorator the "page" object, dunno if it's posible.

[raw] - Pasted by: r0sk on python on Jan. 3, 2012