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


Python Configurator.setup_registry方法代码示例

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


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

示例1: main

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import setup_registry [as 别名]
def main(global_config, **settings):
    """ This function returns a Pyramid WSGI application.
    """
    globalreg = getGlobalSiteManager()
    set_cache_regions_from_settings(settings)
    deserialized_settings = deserialize(settings)

    config = Configurator(registry=globalreg)
    config.setup_registry(settings=settings)

    config.registry.registerUtility(
        deserialized_settings,
        ISettings,
        name='settings'
    )
    config.add_directive('settings_reader', lambda c: SettingsReader(c))
    config.reader = SettingsReader(config)
    config.include('papaye.config.auth')
    config.include('papaye.config.routes')
    config.include('papaye.config.views')
    config.include('papaye.config.startup')
    config.add_renderer(
        name='json_api_compat',
        factory='papaye.views.api.compat.renderers.CompatAPIRendererFactory'
    )
    config.commit()
    config.add_tween('papaye.tweens.LoginRequiredTweenFactory')
    config.scan(ignore=['papaye.tests', 'papaye.conftest'])
    config.set_request_property(
        lambda x: deserialized_settings,
        'papaye_settings',
        reify=True
    )
    return config.make_wsgi_app()
开发者ID:rcommande,项目名称:papaye,代码行数:36,代码来源:__init__.py

示例2: main

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import setup_registry [as 别名]
def main(global_config, **settings):
    """ Return a Pyramid WSGI application. """
    settings['config_uri'] = global_config['__file__']

    config = Configurator(registry=getGlobalSiteManager())
    config.setup_registry(settings=settings)
    config.add_translation_dirs('assembl:locale/')

    def my_locale_negotiator(request):
        locale = default_locale_negotiator(request)
        available = settings['available_languages'].split()
        locale = locale if locale in available else None
        if not locale:
            locale = request.accept_language.best_match(
                available, settings.get('pyramid.default_locale_name', 'en'))
        request._LOCALE_ = locale
        return locale

    config.set_locale_negotiator(my_locale_negotiator)

    config.add_static_view('static', 'static', cache_max_age=3600)
    config.add_static_view('widget', 'widget', cache_max_age=3600)

    config.add_view(maintenance_message)
    config.add_notfound_view(maintenance_message)
    return config.make_wsgi_app()
开发者ID:assembl,项目名称:assembl,代码行数:28,代码来源:maintenance.py

示例3: main

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import setup_registry [as 别名]
def main(global_config, **local_config):
    """
    A paste.httpfactory to wrap a pyramid WSGI based application.
    """
    wconf = global_config.copy()
    wconf.update(**local_config)
    if global_config.get("debug", "False").lower() == "true":
        wconf["pyramid.debug_authorization"] = "true"
        wconf["pyramid.debug_notfound"] = "true"
        wconf["pyramid.reload_templates"] = "true"
        wconf["debugtoolbar.eval_exc"] = "true"
        wconf["debugtoolbar.enabled"] = "true"
    wconf["zcmls"] = utils.splitstrip(wconf["zcmls"])
    if not wconf["zcmls"]:
        wconf["zcmls"] = []
    wconf["zcmls"].insert(0, "configure.zcml")
    for i, zcml in enumerate(wconf["zcmls"]):
        if os.path.sep in zcml:
            zcml = os.path.abspath(zcml)
        else:
            zcml = pkg_resources.resource_filename(dn, zcml)
        wconf["zcmls"][i] = zcml
    globalreg = getGlobalSiteManager()
    config = Configurator(registry=globalreg)
    config.setup_registry(settings=wconf)
    config.include("pyramid_debugtoolbar")
    config.include("pyramid_chameleon")
    config.include("pyramid_zcml")
    config.add_static_view(name="resources", path=here + "/templates/static")
    config.hook_zca()
    for z in wconf["zcmls"]:
        config.load_zcml(z)
    return config.make_wsgi_app()
开发者ID:collective,项目名称:collective.generic.webbuilder,代码行数:35,代码来源:__init__.py

示例4: base_registry

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import setup_registry [as 别名]
def base_registry(request, app_settings):
    from assembl.views.traversal import root_factory
    from pyramid.config import Configurator
    from zope.component import getGlobalSiteManager
    registry = getGlobalSiteManager()
    config = Configurator(registry)
    config.setup_registry(
        settings=app_settings, root_factory=root_factory)
    configure_tasks(registry, 'assembl')
    return registry
开发者ID:hypnotics,项目名称:assembl,代码行数:12,代码来源:pytest_fixtures.py

示例5: base_registry

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import setup_registry [as 别名]
def base_registry(request):
    from assembl.views.traversal import root_factory
    from pyramid.config import Configurator
    from zope.component import getGlobalSiteManager
    registry = getGlobalSiteManager()
    config = Configurator(registry)
    config.setup_registry(
        settings=get_config(), root_factory=root_factory)
    configure_tasks(registry, 'assembl')
    config.add_tween('assembl.tests.pytest_fixtures.zopish_session_tween_factory')
    return registry
开发者ID:Lornz-,项目名称:assembl,代码行数:13,代码来源:pytest_fixtures.py

示例6: _registerComponents

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import setup_registry [as 别名]
    def _registerComponents(self):
        # Install a bit of configuration that make_app() usually
        # does for us.
        reg = get_current_registry()
        config = Configurator(reg, autocommit=True)
        config.setup_registry()
        config.include("pyramid_zcml")
        config.load_zcml("karl.includes:configure.zcml")
        from zope.interface import Interface

        config.registry.registerAdapter(DummyToolAddables, (Interface, Interface), IToolAddables)
开发者ID:Falmarri,项目名称:karl,代码行数:13,代码来源:tests.py

示例7: _registerComponents

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import setup_registry [as 别名]
 def _registerComponents(self):
     # Install a bit of configuration that make_app() usually
     # does for us.
     from karl.application import configure_karl
     reg = get_current_registry()
     config = Configurator(reg, autocommit=True, package='karl.includes')
     config.setup_registry()
     configure_karl(config)
     from zope.interface import Interface
     config.registry.registerAdapter(DummyToolAddables,
                                     (Interface, Interface),
                                     IToolAddables)
开发者ID:claytron,项目名称:karl,代码行数:14,代码来源:tests.py

示例8: base_registry

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import setup_registry [as 别名]
def base_registry(request):
    """A Zope registry that is configured by with the testing.ini"""
    from assembl.views.traversal import root_factory
    from pyramid.config import Configurator
    from zope.component import getGlobalSiteManager
    registry = getGlobalSiteManager()
    config = Configurator(registry)
    config.setup_registry(
        settings=get_config(), root_factory=root_factory)
    configure_tasks(registry, 'assembl')
    config.add_tween('assembl.tests.utils.committing_session_tween_factory')
    return registry
开发者ID:festrade,项目名称:assembl,代码行数:14,代码来源:base.py

示例9: setup_registry

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import setup_registry [as 别名]
 def setup_registry(self,
                    filter_specification_factory=None,
                    order_specification_factory=None,
                    service=None,
                    cql_filter_specification_visitor=None,
                    sql_filter_specification_visitor=None,
                    eval_filter_specification_visitor=None,
                    cql_order_specification_visitor=None,
                    sql_order_specification_visitor=None,
                    eval_order_specification_visitor=None,
                    url_converter=None,
                    **kw):
     # Set default values for options.
     if filter_specification_factory is None:
         filter_specification_factory = FilterSpecificationFactory()
     if order_specification_factory is None:
         order_specification_factory = OrderSpecificationFactory()
     if service is None:
         service = Service()
     if cql_filter_specification_visitor is None:
         cql_filter_specification_visitor = CqlFilterSpecificationVisitor
     if sql_filter_specification_visitor is None:
         sql_filter_specification_visitor = SqlFilterSpecificationVisitor
     if eval_filter_specification_visitor is None:
         eval_filter_specification_visitor = \
                                 ObjectFilterSpecificationVisitor
     if cql_order_specification_visitor is None:
         cql_order_specification_visitor = CqlOrderSpecificationVisitor
     if sql_order_specification_visitor is None:
         sql_order_specification_visitor = SqlOrderSpecificationVisitor
     if eval_order_specification_visitor is None:
         eval_order_specification_visitor = ObjectOrderSpecificationVisitor
     if url_converter is None:
         url_converter = ResourceUrlConverter
     PyramidConfigurator.setup_registry(self, **kw)
     self.__setup_everest(
            filter_specification_factory=filter_specification_factory,
            order_specification_factory=order_specification_factory,
            service=service,
            cql_filter_specification_visitor=
                                 cql_filter_specification_visitor,
            sql_filter_specification_visitor=
                                 sql_filter_specification_visitor,
            eval_filter_specification_visitor=
                                 eval_filter_specification_visitor,
            cql_order_specification_visitor=
                                 cql_order_specification_visitor,
            sql_order_specification_visitor=
                                 sql_order_specification_visitor,
            eval_order_specification_visitor=
                                 eval_order_specification_visitor,
            url_converter=url_converter)
开发者ID:helixyte,项目名称:everest,代码行数:54,代码来源:configuration.py

示例10: main

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import setup_registry [as 别名]
def main(global_config, **settings):
    """ This function returns a Pyramid WSGI application.
    """
    # config = Configurator(settings=settings, root_factory=root_factory)
    globalreg = getGlobalSiteManager()
    config = Configurator(registry=RegistryWrapper(globalreg))
    config.setup_registry(settings=settings)
    config.set_root_factory(root_factory)
    config.include('substanced')
    config.include(pyramid_zcml)
    config.load_zcml("configure.zcml")
    config.scan()
    return config.make_wsgi_app()
开发者ID:plomino,项目名称:rapidosubstanced,代码行数:15,代码来源:__init__.py

示例11: test_registerRoute

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import setup_registry [as 别名]
 def test_registerRoute(self):
     from pyramid.config import Configurator
     from pyramid.request import Request
     from pyramid.interfaces import IRoutesMapper
     from pyramid.testing import registerRoute
     registerRoute(':pagename', 'home', DummyFactory)
     mapper = self.registry.getUtility(IRoutesMapper)
     self.assertEqual(len(mapper.routelist), 1)
     request = Request.blank('/')
     request.registry = self.registry
     config = Configurator(registry=self.registry)
     config.setup_registry()
     self.assertEqual(request.route_url('home', pagename='abc'),
                      'http://localhost/abc')
开发者ID:Javex,项目名称:pyramid,代码行数:16,代码来源:test_testing.py

示例12: make_app

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import setup_registry [as 别名]
def make_app(settings):
    config = Configurator(registry=esauth.registry)
    config.setup_registry(settings=settings)
    if asbool(settings.get('debug')):
        configure_common_debug_options(config)
    configure_ldap_connection(config)
    configure_views(config)
    configure_template_engine(config)
    configure_session(config)
    configure_webassets(config)
    configure_webassets_jinja2_integration(config)
    configure_security(config)
    config.set_root_factory(esauth.resources.Root)
    return config.make_wsgi_app()
开发者ID:attakei,项目名称:esauth,代码行数:16,代码来源:main.py

示例13: ViewsTests

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import setup_registry [as 别名]
class ViewsTests(unittest.TestCase):

    def setup(self):
        # reg = pyramid.registry.Registry('testing')
        wsgiapp = self._load_wsgiapp()
        self.config = Configurator(registry=wsgiapp.registry, package='camtasia_request')
        self.config.setup_registry(settings=settings)
        self.app = TestApp(wsgiapp, extra_environ={})

    def _load_wsgiapp(self):
        wsgiapp = loadapp(ini)
        return wsgiapp

    def _get_app_url(self):
        return 'http://localhost:5000'

    def tearDown(self):
        self.config.end()
        pass
开发者ID:antholo,项目名称:d2lapps,代码行数:21,代码来源:tests.py

示例14: wsgi_app_factory

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import setup_registry [as 别名]
def wsgi_app_factory(global_config, **local_config):
    """
    A paste.httpfactory to wrap a django WSGI based application.
    """
    dn = 'collective.generic.webbuilder'
    wconf = global_config.copy()
    wconf.update(**local_config)
    debug = False
    if global_config.get('debug', 'False').lower() == 'true':
        debug = True
        wconf['pyramid.debug_authorization'] = 'true'
        wconf['pyramid.debug_notfound'] = 'true'
        wconf['pyramid.reload_templates'] = 'true'
    wconf['zcmls' ] = utils.splitstrip(wconf['zcmls'])
    if not wconf['zcmls']:
        wconf['zcmls'] = []
    wconf['zcmls'].insert(0, 'configure.zcml')
    for i, zcml in enumerate(wconf['zcmls']):
        if os.path.sep in zcml:
            zcml = os.path.abspath(zcml)
        else:
            zcml = pkg_resources.resource_filename(dn, zcml)
        wconf['zcmls'][i] = zcml 

    globalreg = getGlobalSiteManager() 
    config = Configurator(registry=globalreg)
    config.setup_registry(settings=wconf)
    config.include('pyramid_zcml')
    config.hook_zca()
    for z in wconf['zcmls']:
        config.load_zcml(z)  
    app = config.make_wsgi_app()
    def webbuilder_app(environ, start_response):
        req = Request(environ)
        try:
            resp = req.get_response(app)
            return resp(environ, start_response)
        except Exception, e:
            if not debug:
                return exc.HTTPServerError(str(e))(environ, start_response)
            else:
                raise
开发者ID:numahell,项目名称:collective.generic.webbuilder,代码行数:44,代码来源:webserver.py

示例15: registerRoute

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import setup_registry [as 别名]
def registerRoute(pattern, name, factory=None):
    """ Register a new :term:`route` using a pattern
    (e.g. ``:pagename``), a name (e.g. ``home``), and an optional root
    factory.

    The ``pattern`` argument implies the route pattern.  The ``name``
    argument implies the route name.  The ``factory`` argument implies
    a :term:`root factory` associated with the route.

    This API is useful for testing code that calls
    e.g. :func:`pyramid.url.route_url`.

    .. warning:: This API is deprecated as of :app:`Pyramid` 1.0.
       Instead use the
       :meth:`pyramid.config.Configurator.add_route`
       method in your unit and integration tests.
    """
    reg = get_current_registry()
    config = Configurator(registry=reg)
    config.setup_registry()
    result = config.add_route(name, pattern, factory=factory)
    config.commit()
    return result
开发者ID:Javex,项目名称:pyramid,代码行数:25,代码来源:testing.py


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