当前位置: 首页>>代码示例>>Python>>正文


Python Registry.getMultiAdapter方法代码示例

本文整理汇总了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
开发者ID:pra85,项目名称:adhocracy3,代码行数:11,代码来源:subscriber.py

示例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
开发者ID:Janaba,项目名称:adhocracy3,代码行数:12,代码来源:__init__.py

示例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
开发者ID:robx,项目名称:adhocracy3.mercator,代码行数:6,代码来源:import_users.py

示例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()
开发者ID:Janaba,项目名称:adhocracy3,代码行数:6,代码来源:ad_export_users.py


注:本文中的pyramid.registry.Registry.getMultiAdapter方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。