Created
September 28, 2012 09:55
-
-
Save Sanqui/3798944 to your computer and use it in GitHub Desktop.
minpowerlevel() decorator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from flask import abort | |
# Callable decorator | |
def minpowerlevel(powerlevel): | |
def decorator(function): | |
@wraps(function) | |
def f(*args, **kvargs): | |
if g.user.powerlevel >= powerlevel: | |
return function(*args, **kvargs) | |
else: | |
return abort(403) | |
return f | |
return decorator |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment