• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python registry.Registry类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: test__find_view_traversal_multiview

    def test__find_view_traversal_multiview(self):
        from zope.interface import implementer
        from zope.interface import providedBy
        from pyramid.interfaces import IRequest
        from pyramid.interfaces import IViewClassifier
        from pyramid.interfaces import IMultiView
        from pyramid.traversal import DefaultRootFactory
        from pyramid.registry import Registry

        registry = Registry()

        @implementer(IMultiView)
        class View1(object):
            pass

        request = dummy.DummyRequest()
        request.path_info = '/a'
        root = DefaultRootFactory(request)
        root_iface = providedBy(root)
        view = View1()
        registry.registerAdapter(
            view, (IViewClassifier, IRequest, root_iface), IMultiView, name='a'
        )
        self._register_mapper(registry, [])
        command = self._makeOne(registry=registry)
        request = self._makeRequest('/a', registry)
        result = command._find_view(request)
        self.assertEqual(result, view)
开发者ID:Pylons,项目名称:pyramid,代码行数:28,代码来源:test_pviews.py


示例2: test__find_view_route_no_multiview

 def test__find_view_route_no_multiview(self):
     from zope.interface import Interface
     from zope.interface import implementer
     from pyramid.interfaces import IRouteRequest
     from pyramid.interfaces import IViewClassifier
     from pyramid.interfaces import IView
     from pyramid.registry import Registry
     registry = Registry()
     def view():pass
     class IMyRoot(Interface):
         pass
     class IMyRoute(Interface):
         pass
     registry.registerAdapter(view,
                              (IViewClassifier, IMyRoute, IMyRoot),
                              IView, '')
     registry.registerUtility(IMyRoute, IRouteRequest, name='a')
     @implementer(IMyRoot)
     class Factory(object):
         def __init__(self, request):
             pass
     routes = [dummy.DummyRoute('a', '/a', factory=Factory, matchdict={}),
               dummy.DummyRoute('b', '/b', factory=Factory)]
     self._register_mapper(registry, routes)
     command = self._makeOne(registry=registry)
     result = command._find_view('/a', registry)
     self.assertEqual(result, view)
开发者ID:HorizonXP,项目名称:pyramid,代码行数:27,代码来源:test_pviews.py


示例3: setUp

 def setUp(self):
     self.__request = DummyRequest()
     self.__request.matchdict['registration_id'] = 'a1-b2-c3-d4-e5'
     self.__request.headers['File-Name'] = 'dummy.zip'
     reg = Registry()
     reg.settings = {'hpz.frs.upload_base_path': '/dev/null', 'hpz.frs.file_size_limit': '1024'}
     self.__config = testing.setUp(registry=reg, request=self.__request, hook_zca=False)
开发者ID:SmarterApp,项目名称:RDW_DataWarehouse,代码行数:7,代码来源:test_upload_service.py


示例4: test_single_route_one_view_registered_with_factory

 def test_single_route_one_view_registered_with_factory(self):
     from zope.interface import Interface
     from pyramid.registry import Registry
     from pyramid.interfaces import IRouteRequest
     from pyramid.interfaces import IViewClassifier
     from pyramid.interfaces import IView
     registry = Registry()
     def view():pass
     class IMyRoot(Interface):
         pass
     class IMyRoute(Interface):
         pass
     registry.registerAdapter(view,
                              (IViewClassifier, IMyRoute, IMyRoot),
                              IView, '')
     registry.registerUtility(IMyRoute, IRouteRequest, name='a')
     command = self._makeOne()
     def factory(request): pass
     route = dummy.DummyRoute('a', '/a', factory=factory)
     mapper = dummy.DummyMapper(route)
     command._get_mapper = lambda *arg: mapper
     L = []
     command.out = L.append
     command.bootstrap = (dummy.DummyBootstrap(registry=registry),)
     result = command.run()
     self.assertEqual(result, None)
     self.assertEqual(len(L), 3)
     self.assertEqual(L[-1].split()[:3], ['a', '/a', '<unknown>'])
开发者ID:HorizonXP,项目名称:pyramid,代码行数:28,代码来源:test_proutes.py


示例5: setUp

 def setUp(self):
     self.__workspace = tempfile.mkdtemp()
     self.__staging = tempfile.mkdtemp()
     # setup request
     self.__request = DummyRequest()
     self.__request.method = 'POST'
     # setup settings
     # use the one for UDL
     here = os.path.abspath(os.path.dirname(__file__))
     self.gpg_home = os.path.abspath(os.path.join(here, '..', '..', '..', '..', 'config', 'gpg'))
     self.settings = {
         'smarter_score_batcher.gpg.keyserver': None,
         'smarter_score_batcher.gpg.homedir': self.gpg_home,
         'smarter_score_batcher.gpg.public_key.ca': '[email protected]',
         'smarter_score_batcher.gpg.public_key.cat': '[email protected]',
         'smarter_score_batcher.gpg.public_key.fish': '[email protected]',
         'smarter_score_batcher.gpg.path': 'gpg',
         'smarter_score_batcher.base_dir.working': self.__workspace,
         'smarter_score_batcher.base_dir.staging': self.__staging
     }
     # setup registr
     reg = Registry()
     reg.settings = self.settings
     self.__config = testing.setUp(registry=reg, request=self.__request, hook_zca=False)
     self._prepare_testing_files()
开发者ID:,项目名称:,代码行数:25,代码来源:


示例6: test_single_route_one_view_registered

    def test_single_route_one_view_registered(self):
        from zope.interface import Interface
        from pyramid.registry import Registry
        from pyramid.interfaces import IRouteRequest
        from pyramid.interfaces import IViewClassifier
        from pyramid.interfaces import IView

        registry = Registry()

        def view():
            pass

        class IMyRoute(Interface):
            pass

        registry.registerAdapter(view, (IViewClassifier, IMyRoute, Interface), IView, "")
        registry.registerUtility(IMyRoute, IRouteRequest, name="a")
        command = self._makeOne()
        route = DummyRoute("a", "/a")
        mapper = DummyMapper(route)
        command._get_mapper = lambda *arg: mapper
        L = []
        command.out = L.append
        app = DummyApp()
        app.registry = registry
        loadapp = DummyLoadApp(app)
        command.loadapp = (loadapp,)
        command.args = ("/foo/bar/myapp.ini", "myapp")
        result = command.command()
        self.assertEqual(result, None)
        self.assertEqual(len(L), 3)
        self.assertEqual(L[-1].split()[:4], ["a", "/a", "<function", "view"])
开发者ID:nak,项目名称:Penumbra,代码行数:32,代码来源:test_paster.py


示例7: test_single_route_one_view_registered

 def test_single_route_one_view_registered(self):
     from zope.interface import Interface
     from pyramid.registry import Registry
     from pyramid.interfaces import IRouteRequest
     from pyramid.interfaces import IViewClassifier
     from pyramid.interfaces import IView
     registry = Registry()
     def view():pass
     class IMyRoute(Interface):
         pass
     registry.registerAdapter(view,
                              (IViewClassifier, IMyRoute, Interface),
                              IView, '')
     registry.registerUtility(IMyRoute, IRouteRequest, name='a')
     command = self._makeOne()
     route = dummy.DummyRoute('a', '/a')
     mapper = dummy.DummyMapper(route)
     command._get_mapper = lambda *arg: mapper
     L = []
     command.out = L.append
     command.bootstrap = (dummy.DummyBootstrap(registry=registry),)
     result = command.run()
     self.assertEqual(result, 0)
     self.assertEqual(len(L), 3)
     compare_to = L[-1].split()[:3]
     self.assertEqual(
         compare_to,
         ['a', '/a', 'pyramid.tests.test_scripts.test_proutes.view']
     )
开发者ID:AdrianTeng,项目名称:pyramid,代码行数:29,代码来源:test_proutes.py


示例8: test__find_view_route_multiview_no_view_registered

 def test__find_view_route_multiview_no_view_registered(self):
     from zope.interface import Interface
     from zope.interface import implementer
     from pyramid.interfaces import IRouteRequest
     from pyramid.interfaces import IMultiView
     from pyramid.interfaces import IRootFactory
     from pyramid.registry import Registry
     registry = Registry()
     def view1():pass
     def view2():pass
     class IMyRoot(Interface):
         pass
     class IMyRoute1(Interface):
         pass
     class IMyRoute2(Interface):
         pass
     registry.registerUtility(IMyRoute1, IRouteRequest, name='a')
     registry.registerUtility(IMyRoute2, IRouteRequest, name='b')
     @implementer(IMyRoot)
     class Factory(object):
         def __init__(self, request):
             pass
     registry.registerUtility(Factory, IRootFactory)
     routes = [dummy.DummyRoute('a', '/a', matchdict={}),
               dummy.DummyRoute('b', '/a', matchdict={})]
     self._register_mapper(registry, routes)
     command = self._makeOne(registry=registry)
     result = command._find_view('/a', registry)
     self.assertTrue(IMultiView.providedBy(result))
开发者ID:HorizonXP,项目名称:pyramid,代码行数:29,代码来源:test_pviews.py


示例9: test_single_route_one_view_registered_with_factory

 def test_single_route_one_view_registered_with_factory(self):
     from zope.interface import Interface
     from pyramid.registry import Registry
     from pyramid.interfaces import IRouteRequest
     from pyramid.interfaces import IViewClassifier
     from pyramid.interfaces import IView
     registry = Registry()
     def view():pass
     class IMyRoot(Interface):
         pass
     class IMyRoute(Interface):
         pass
     registry.registerAdapter(view,
                              (IViewClassifier, IMyRoute, IMyRoot),
                              IView, '')
     registry.registerUtility(IMyRoute, IRouteRequest, name='a')
     command = self._makeOne()
     def factory(request): pass
     route = DummyRoute('a', '/a', factory=factory)
     mapper = DummyMapper(route)
     command._get_mapper = lambda *arg: mapper
     L = []
     command.out = L.append
     app = DummyApp()
     app.registry = registry
     loadapp = DummyLoadApp(app)
     command.loadapp = (loadapp,)
     command.args = ('/foo/bar/myapp.ini', 'myapp')
     result = command.command()
     self.assertEqual(result, None)
     self.assertEqual(len(L), 3)
     self.assertEqual(L[-1].split()[:3], ['a', '/a', '<unknown>'])
开发者ID:jgonera,项目名称:pyramid,代码行数:32,代码来源:test_paster.py


示例10: _makeRequest

 def _makeRequest(self, **kwargs):
     """:rtype: pyramid.request.Request"""
     from pyramid.registry import Registry
     registry = Registry()
     registry.settings = {'app.timezone': 'Asia/Bangkok'}
     testing.setUp(registry=registry)
     return testing.DummyRequest(**kwargs)
开发者ID:,项目名称:,代码行数:7,代码来源:


示例11: test_dn_with_one_base_element

 def test_dn_with_one_base_element(self):
     reg = Registry()
     reg.settings = {}
     reg.settings['ldap.base.dn'] = 'ou=dummy'
     self.__config = testing.setUp(registry=reg, request=DummyRequest(), hook_zca=False)
     attributes = {'dn': ['ou=dummyOrg,ou=dummy']}
     tenant = BasicIdentityParser.get_tenant_name(attributes)
     self.assertEqual(tenant[0], 'dummyorg')
开发者ID:SmarterApp,项目名称:RDW_DataWarehouse,代码行数:8,代码来源:test_basic_identity_parser.py


示例12: setUp

 def setUp(self):
     reg = Registry()
     reg.settings = {'store_type':'rdflib',
                     'debug_sparql':True}
     self.config = testing.setUp(reg)
     self.config.add_settings({'mako.directories':'plingback.sparql:templates'})
     self.config.add_renderer(None, mako_renderer_factory)
     self.config.begin()
开发者ID:neontribe,项目名称:PlingBack,代码行数:8,代码来源:tests.py


示例13: test_add_settings_settings_None

 def test_add_settings_settings_None(self):
     from pyramid.registry import Registry
     from pyramid.interfaces import ISettings
     reg = Registry()
     config = self._makeOne(reg)
     config.add_settings(None, a=1)
     settings = reg.getUtility(ISettings)
     self.assertEqual(settings['a'], 1)
开发者ID:JDeuce,项目名称:pyramid,代码行数:8,代码来源:test_settings.py


示例14: get_registry

def get_registry(settings):
    registry = Registry('testing')
    config = Configurator(registry=registry)
    if getattr(registry, 'settings', None) is None:
        config._set_settings(settings)
    registry.registerUtility(RoutesMapper(), IRoutesMapper)
    config.commit()
    return registry
开发者ID:ATRAN2,项目名称:pyramid_swagger,代码行数:8,代码来源:response_test.py


示例15: test_setup_registry_debug_logger_None_default

    def test_setup_registry_debug_logger_None_default(self):
        from pyramid.registry import Registry
        from pyramid.interfaces import IDebugLogger

        reg = Registry()
        config = self._makeOne(reg)
        config.setup_registry()
        logger = reg.getUtility(IDebugLogger)
        self.assertEqual(logger.name, 'tests.test_config')
开发者ID:Pylons,项目名称:pyramid,代码行数:9,代码来源:test_init.py


示例16: _set_local_roles

def _set_local_roles(resource, new_local_roles: dict, registry: Registry):
    old_local_roles = getattr(resource, '__local_roles__', None)
    if new_local_roles == old_local_roles:
        return
    else:
        resource.__local_roles__ = new_local_roles
    event = LocalRolesModified(resource, new_local_roles, old_local_roles,
                               registry)
    registry.notify(event)
开发者ID:liqd,项目名称:adhocracy3,代码行数:9,代码来源:__init__.py


示例17: setUp

 def setUp(self):
     reg = Registry()
     reg.settings = {}
     reg.settings['session.backend.type'] = 'beaker'
     reg.settings['cache.expire'] = 10
     reg.settings['cache.regions'] = 'session'
     reg.settings['cache.type'] = 'memory'
     reg.settings['batch.user.session.timeout'] = 15
     component.provideUtility(SessionBackend(reg.settings), ISessionBackend)
开发者ID:SmarterApp,项目名称:RDW_DataWarehouse,代码行数:9,代码来源:test_batch_user_session.py


示例18: test_setup_registry_default_permission

    def test_setup_registry_default_permission(self):
        from pyramid.registry import Registry
        from pyramid.interfaces import IDefaultPermission

        reg = Registry()
        config = self._makeOne(reg)
        config.setup_registry(default_permission='view')
        config.commit()
        self.assertEqual(reg.getUtility(IDefaultPermission), 'view')
开发者ID:Pylons,项目名称:pyramid,代码行数:9,代码来源:test_init.py


示例19: test_setup_registry_no_default_root_factory

    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,代码行数:9,代码来源:test_init.py


示例20: test_setup_registry_debug_logger_name

    def test_setup_registry_debug_logger_name(self):
        from pyramid.registry import Registry
        from pyramid.interfaces import IDebugLogger

        reg = Registry()
        config = self._makeOne(reg)
        config.setup_registry(debug_logger='foo')
        result = reg.getUtility(IDebugLogger)
        self.assertEqual(result.name, 'foo')
开发者ID:Pylons,项目名称:pyramid,代码行数:9,代码来源:test_init.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python renderers.get_renderer函数代码示例发布时间:2022-05-27
下一篇:
Python path.DottedNameResolver类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap