Skip to content

Instantly share code, notes, and snippets.

@Sanqui
Created September 28, 2012 09:55
Show Gist options
  • Save Sanqui/3798944 to your computer and use it in GitHub Desktop.
Save Sanqui/3798944 to your computer and use it in GitHub Desktop.
minpowerlevel() decorator
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