本文整理匯總了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)