def perm_check(function, perm_check_func=_perm_check_func, raise_exception=False):
def real_decorator(func):<EOL><INDENT>def wrapped(request, db, col, cmd, *args, **kwargs):<EOL><INDENT>bPermPass = perm_check_func(request, db, col, cmd) if perm_check_func else True<EOL>if raise_exception and (not bPermPass):<EOL><INDENT>raise PermissionDenied<EOL><DEDENT>return func(request, db, col, cmd, *args, **kwargs) if bPermPass else {"<STR_LIT:error>": "<STR_LIT>"}<EOL><DEDENT>return wrapped<EOL><DEDENT>return real_decorator(function)<EOL>
perm_check_func: the auth func with parameter db,col,cmd
raise_exception: True: raise http 403 exception if permission check failed, otherwise return a JSON