def dyn_perm(self, action): from germ.lib.misc import always_false, always_true, call_if if isinstance(self.__perm, dict): # TODO: always return true self.__perm.has_key but PK not set return call_if(self.__perm.get(action, always_false), self) else: return action in self.__perm
def accept(self, action): from germ.lib.misc import call_if # The tests are evaluated in the following order. If any of the tests # is not specified, proceed to the next item. # # 1. 'none': If this fails, deny permission, otherwise proceed. # 2. act_str: This either denies or grants permission. Only proceed # to the next test if act_str specification does not # exist. # 3. 'all': If this fails, deny permission # 4. grant permission # if not (call_if(self.__perm.get('none', True)) and \ call_if(self.__perm.get(str(action), call_if(self.__perm.get('all', True))))): from germ.error.perm_denied import perm_denied raise perm_denied() self.do_accept(action)
def magic_var(self, var): magic_func = self.__magic_var.get(var) from germ.lib.misc import call_if return call_if(magic_func)
def set_default(self): if self.__default is None: return from germ.lib.misc import call_if self.set(call_if(self.__default))