本文整理汇总了Python中pyramid.registry.Registry.getMultiAdapter方法的典型用法代码示例。如果您正苦于以下问题:Python Registry.getMultiAdapter方法的具体用法?Python Registry.getMultiAdapter怎么用?Python Registry.getMultiAdapter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyramid.registry.Registry
的用法示例。
在下文中一共展示了Registry.getMultiAdapter方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _get_user_groups
# 需要导入模块: from pyramid.registry import Registry [as 别名]
# 或者: from pyramid.registry.Registry import getMultiAdapter [as 别名]
def _get_user_groups(user: IUser, registry: Registry):
from pyramid.traversal import resource_path
from adhocracy_core.interfaces import IRolesUserLocator
request = Request.blank('/')
request.registry = registry
locator = registry.getMultiAdapter((user, request), IRolesUserLocator)
user_id = resource_path(user)
groups = locator.get_groups(user_id)
return groups
示例2: _get_creator
# 需要导入模块: from pyramid.registry import Registry [as 别名]
# 或者: from pyramid.registry.Registry import getMultiAdapter [as 别名]
def _get_creator(resource_info: dict,
context: IResource,
registry: Registry,
request: Request) -> IResource:
creator_name = resource_info.get('creator', None)
if not creator_name:
return None
locator = registry.getMultiAdapter((context, request), IUserLocator)
creator = locator.get_user_by_login(creator_name)
return creator
示例3: _get_user_locator
# 需要导入模块: from pyramid.registry import Registry [as 别名]
# 或者: from pyramid.registry.Registry import getMultiAdapter [as 别名]
def _get_user_locator(context: IResource, registry: Registry) -> IUserLocator:
request = Request.blank('/dummy')
locator = registry.getMultiAdapter((context, request), IUserLocator)
return locator
示例4: _get_users
# 需要导入模块: from pyramid.registry import Registry [as 别名]
# 或者: from pyramid.registry.Registry import getMultiAdapter [as 别名]
def _get_users(root: IResource, registry: Registry) -> [IUser]:
request = Request.blank('/dummy')
locator = registry.getMultiAdapter((root, request), IUserLocator)
return locator.get_users()