本文整理汇总了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)
示例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)
示例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
示例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)
示例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)
示例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)
示例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)
示例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
示例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
示例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
示例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