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


Python Registry.queryUtility方法代码示例

本文整理汇总了Python中pyramid.registry.Registry.queryUtility方法的典型用法代码示例。如果您正苦于以下问题:Python Registry.queryUtility方法的具体用法?Python Registry.queryUtility怎么用?Python Registry.queryUtility使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pyramid.registry.Registry的用法示例。


在下文中一共展示了Registry.queryUtility方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_social_login_mapper

# 需要导入模块: from pyramid.registry import Registry [as 别名]
# 或者: from pyramid.registry.Registry import queryUtility [as 别名]
def get_social_login_mapper(registry: Registry, provider_id: str) -> ISocialLoginMapper:
    """Get a named social login mapper.

    Example::

        get_social_login_mapper(registry, "facebook")

    """
    return registry.queryUtility(ISocialLoginMapper, name=provider_id)
开发者ID:websauna,项目名称:websauna,代码行数:11,代码来源:utils.py

示例2: test_setup_registry_no_default_root_factory

# 需要导入模块: from pyramid.registry import Registry [as 别名]
# 或者: from pyramid.registry.Registry import queryUtility [as 别名]
    def test_setup_registry_no_default_root_factory(self):
        from pyramid.registry import Registry
        from pyramid.interfaces import IRootFactory

        reg = Registry()
        config = self._makeOne(reg)
        config.setup_registry()
        config.commit()
        self.assertEqual(reg.queryUtility(IRootFactory), None)
开发者ID:Pylons,项目名称:pyramid,代码行数:11,代码来源:test_init.py

示例3: get_authomatic

# 需要导入模块: from pyramid.registry import Registry [as 别名]
# 或者: from pyramid.registry.Registry import queryUtility [as 别名]
def get_authomatic(registry: Registry) -> Authomatic:
    """Get active Authomatic instance from the registry.

    This is registed in ``Initializer.configure_authomatic()``.
    :param registry:
    :return:
    """
    instance = registry.queryUtility(IAuthomatic)
    return instance
开发者ID:websauna,项目名称:websauna,代码行数:11,代码来源:utils.py

示例4: test_setup_registry_response_factory

# 需要导入模块: from pyramid.registry import Registry [as 别名]
# 或者: from pyramid.registry.Registry import queryUtility [as 别名]
    def test_setup_registry_response_factory(self):
        from pyramid.registry import Registry
        from pyramid.interfaces import IResponseFactory

        reg = Registry()
        config = self._makeOne(reg)
        factory = lambda r: object()
        config.setup_registry(response_factory=factory)
        self.assertEqual(reg.queryUtility(IResponseFactory), None)
        config.commit()
        utility = reg.getUtility(IResponseFactory)
        self.assertEqual(utility, factory)
开发者ID:Pylons,项目名称:pyramid,代码行数:14,代码来源:test_init.py

示例5: test_setup_registry_locale_negotiator

# 需要导入模块: from pyramid.registry import Registry [as 别名]
# 或者: from pyramid.registry.Registry import queryUtility [as 别名]
    def test_setup_registry_locale_negotiator(self):
        from pyramid.registry import Registry
        from pyramid.interfaces import ILocaleNegotiator

        reg = Registry()
        config = self._makeOne(reg)
        negotiator = object()
        config.setup_registry(locale_negotiator=negotiator)
        self.assertEqual(reg.queryUtility(ILocaleNegotiator), None)
        config.commit()
        utility = reg.getUtility(ILocaleNegotiator)
        self.assertEqual(utility, negotiator)
开发者ID:Pylons,项目名称:pyramid,代码行数:14,代码来源:test_init.py

示例6: test_setup_registry_dottedname_root_factory

# 需要导入模块: from pyramid.registry import Registry [as 别名]
# 或者: from pyramid.registry.Registry import queryUtility [as 别名]
    def test_setup_registry_dottedname_root_factory(self):
        from pyramid.registry import Registry
        from pyramid.interfaces import IRootFactory

        reg = Registry()
        config = self._makeOne(reg)
        import tests.test_config

        config.setup_registry(root_factory='tests.test_config')
        self.assertEqual(reg.queryUtility(IRootFactory), None)
        config.commit()
        self.assertEqual(reg.getUtility(IRootFactory), tests.test_config)
开发者ID:Pylons,项目名称:pyramid,代码行数:14,代码来源:test_init.py

示例7: test_setup_registry_locale_negotiator_dottedname

# 需要导入模块: from pyramid.registry import Registry [as 别名]
# 或者: from pyramid.registry.Registry import queryUtility [as 别名]
    def test_setup_registry_locale_negotiator_dottedname(self):
        from pyramid.registry import Registry
        from pyramid.interfaces import ILocaleNegotiator

        reg = Registry()
        config = self._makeOne(reg)
        import tests.test_config

        config.setup_registry(locale_negotiator='tests.test_config')
        self.assertEqual(reg.queryUtility(ILocaleNegotiator), None)
        config.commit()
        utility = reg.getUtility(ILocaleNegotiator)
        self.assertEqual(utility, tests.test_config)
开发者ID:Pylons,项目名称:pyramid,代码行数:15,代码来源:test_init.py

示例8: get_site_creator

# 需要导入模块: from pyramid.registry import Registry [as 别名]
# 或者: from pyramid.registry.Registry import queryUtility [as 别名]
def get_site_creator(registry: Registry) -> ISiteCreator:
    site_creator = registry.queryUtility(ISiteCreator)
    return site_creator
开发者ID:websauna,项目名称:websauna,代码行数:5,代码来源:utils.py

示例9: get_activation_model

# 需要导入模块: from pyramid.registry import Registry [as 别名]
# 或者: from pyramid.registry.Registry import queryUtility [as 别名]
def get_activation_model(registry: Registry) -> IActivationModel:
    activation_model = registry.queryUtility(IActivationModel)
    return activation_model
开发者ID:websauna,项目名称:websauna,代码行数:5,代码来源:utils.py

示例10: get_group_class

# 需要导入模块: from pyramid.registry import Registry [as 别名]
# 或者: from pyramid.registry.Registry import queryUtility [as 别名]
def get_group_class(registry: Registry) -> IGroupModel:
    group_class = registry.queryUtility(IGroupModel)
    return group_class
开发者ID:websauna,项目名称:websauna,代码行数:5,代码来源:utils.py

示例11: get_user_class

# 需要导入模块: from pyramid.registry import Registry [as 别名]
# 或者: from pyramid.registry.Registry import queryUtility [as 别名]
def get_user_class(registry: Registry) -> IUserModel:
    user_class = registry.queryUtility(IUserModel)
    return user_class
开发者ID:websauna,项目名称:websauna,代码行数:5,代码来源:utils.py


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