當前位置: 首頁>>代碼示例>>Python>>正文


Python Role.by_foreign_id方法代碼示例

本文整理匯總了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
開發者ID:nivertech,項目名稱:aleph,代碼行數:11,代碼來源:authz.py

示例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)
開發者ID:01-,項目名稱:aleph,代碼行數:11,代碼來源:permission.py

示例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)
開發者ID:DavidLemayian,項目名稱:aleph,代碼行數:11,代碼來源:permission.py

示例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)
開發者ID:pudo,項目名稱:aleph,代碼行數:5,代碼來源:util.py


注:本文中的aleph.model.Role.by_foreign_id方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。