def list(self, owner=None, channel=None, cid=None, key=None): """ 权限列表 """ kwargs = {} if owner: kwargs["owner"] = owner if channel: kwargs["channel"] = channel if cid: kwargs["cid"] = cid if key and (key in PERM_CLASS.keys()): kwargs["value"] = PERM_CLASS[key] r = self.find(**kwargs) if r[0]: return self._output(result=r[1]) else: return None
def query(self, owner=None, channel=None, cid=None, key=None, limit=None, order_by="added_id", order=-1): """ 显示别表 """ kwargs = {} if owner: kwargs["owner"] = owner if channel: kwargs["channel"] = channel if cid: kwargs["cid"] = cid if key and (key in PERM_CLASS.keys()): kwargs["value"] = PERM_CLASS[key] kwargs["limit"] = limit kwargs["order_by"] = order_by kwargs["order"] = order r = super(PermissionAPI, self).find(**kwargs) if r[0]: kw = {"result": r[1]} l = self._output(**kw) return (True, l) else: return (False, r[1])
def award(self, owner, channel, key, cid=None, **kwargs): """ 授权 """ if key not in PERM_CLASS.keys(): return (False, "beyond key") value = unicode(key) return super(PermissionAPI, self).create(owner=owner, channel=channel, cid=cid, value=value, **kwargs)