Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # define some decorators here, to be used by modules for access control
- def access(*a, **kw):
- def check_access(f, *args, **kwargs):
- def new_f(*args, **kwargs):
- session = Session()
- try:
- # query the database to check to see if the user is a master or owner
- query = session.query(User).filter(User.name == args[1]['source']['nick'])
- user = query.first()
- except Exception, e:
- print e
- # check to see if we receive a result from the database and that
- # their access level is at least master status
- if user and user.access >= Access.__getattribute__(a[0]).index:
- return f(*args, **kwargs)
- new_f.func_name = f.func_name
- return new_f
- return check_access
- def master(f):
- return access('master')(f)
Add Comment
Please, Sign In to add comment