本文整理汇总了Python中aleph.model.Role.by_foreign_id方法的典型用法代码示例。如果您正苦于以下问题:Python Role.by_foreign_id方法的具体用法?Python Role.by_foreign_id怎么用?Python Role.by_foreign_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类aleph.model.Role
的用法示例。
在下文中一共展示了Role.by_foreign_id方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_public_roles
# 需要导入模块: from aleph.model import Role [as 别名]
# 或者: from aleph.model.Role import by_foreign_id [as 别名]
def get_public_roles():
app = current_app._get_current_object()
if not hasattr(app, '_public_roles') or not len(app._public_roles):
roles = [
Role.by_foreign_id(Role.SYSTEM_GUEST),
Role.by_foreign_id(Role.SYSTEM_USER)
]
app._public_roles = [r.id for r in roles if r is not None]
return app._public_roles
示例2: grant_foreign
# 需要导入模块: from aleph.model import Role [as 别名]
# 或者: from aleph.model.Role import by_foreign_id [as 别名]
def grant_foreign(cls, resource, foreign_id, read, write):
from aleph.model import Source, Collection, Role
role = Role.by_foreign_id(foreign_id)
if role is None:
return
if isinstance(resource, Source):
cls.grant_resource(cls.SOURCE, resource.id, role, read, write)
if isinstance(resource, Collection):
cls.grant_resource(cls.COLLECTION, resource.id, role, read, write)
示例3: grant_foreign
# 需要导入模块: from aleph.model import Role [as 别名]
# 或者: from aleph.model.Role import by_foreign_id [as 别名]
def grant_foreign(cls, resource, foreign_id, read, write):
from aleph.model import Source, Watchlist, Role
role = Role.by_foreign_id(foreign_id)
if role is None:
return
if isinstance(resource, Source):
cls.grant_resource(cls.SOURCE, resource.id, role, read, write)
if isinstance(resource, Watchlist):
cls.grant_resource(cls.WATCHLIST, resource.id, role, read, write)
示例4: grant_publish
# 需要导入模块: from aleph.model import Role [as 别名]
# 或者: from aleph.model.Role import by_foreign_id [as 别名]
def grant_publish(self, collection):
visitor = Role.by_foreign_id(Role.SYSTEM_GUEST)
self.grant(collection, visitor, True, False)