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


Python Configurator.load_zcml方法代码示例

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


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

示例1: main

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import load_zcml [as 别名]
def main(global_config, **settings):
    """Returns WSGI application.
    """
    import cone.app.security as security
    security.ADMIN_USER = settings.get('cone.admin_user', 'admin')
    security.ADMIN_PASSWORD = settings.get('cone.admin_password', 'admin')
    secret_password = settings.get('cone.secret_password', 'secret')
    authn_factory = settings.get('cone.authn_policy_factory', auth_tkt_factory)
    authz_factory = settings.get('cone.authz_policy_factory', acl_factory)
    config = Configurator(
        root_factory=get_root,
        settings=settings,
        authentication_policy=authn_factory(secret=secret_password,
                                            max_age=43200,
                                            include_ip=True),
        authorization_policy=authz_factory(secret=secret_password),
        autocommit=True)
    zcml_file = settings.get('configure_zcml', 'configure.zcml')
    config.include(pyramid_zcml)
    config.begin()
    config.load_zcml(zcml_file)

    theme_dir = os.path.join(APP_PATH, 'etc', 'theme', '')
    theme_css = os.path.join(APP_PATH, 'etc', 'theme', 'theme.css')
    if os.path.isdir(theme_dir):
        config.add_static_view('theme', theme_dir)
    if os.path.isfile(theme_css):
        import cone.app.browser
        cone.app.browser.ADDITIONAL_CSS.append('theme/theme.css')

    config.end()
    return config.make_wsgi_app()
开发者ID:chaoflownet,项目名称:cone.ugm,代码行数:34,代码来源:run.py

示例2: main

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import load_zcml [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

示例3: base_configure

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import load_zcml [as 别名]
def base_configure(global_config, **settings):
    # Resolve dotted names in settings, include plug-ins and create a
    # Configurator.

    from kotti.resources import get_root

    for key, value in conf_defaults.items():
        settings.setdefault(key, value)

    for key, value in settings.items():
        if key.startswith('kotti') and isinstance(value, basestring):
            settings[key] = unicode(value, 'utf8')

    # Allow extending packages to change 'settings' w/ Python:
    k = 'kotti.configurators'
    for func in _resolve_dotted(settings, keys=(k,))[k]:
        func(settings)

    settings = _resolve_dotted(settings)
    secret1 = settings['kotti.secret']
    settings.setdefault('kotti.secret2', secret1)

    # We'll process ``pyramid_includes`` later by hand, to allow
    # overrides of configuration from ``kotti.base_includes``:
    pyramid_includes = settings.pop('pyramid.includes', '')

    config = Configurator(
        request_factory=settings['kotti.request_factory'][0],
        settings=settings)
    config.begin()

    config.hook_zca()
    config.include('pyramid_zcml')

    # Chameleon bindings were removed from Pyramid core since pyramid>=1.5a2
    config.include('pyramid_chameleon')

    config.registry.settings['pyramid.includes'] = pyramid_includes

    # Include modules listed in 'kotti.base_includes':
    for module in settings['kotti.base_includes']:
        config.include(module)
    config.commit()

    # Modules in 'pyramid.includes' and 'kotti.zcml_includes' may
    # override 'kotti.base_includes':
    if pyramid_includes:
        for module in pyramid_includes.split():
            config.include(module)

    for name in settings['kotti.zcml_includes'].strip().split():
        config.load_zcml(name)

    config.commit()

    config._set_root_factory(get_root)

    return config
开发者ID:adamcheasley,项目名称:Kotti,代码行数:60,代码来源:__init__.py

示例4: main

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import load_zcml [as 别名]
def main(global_config, **settings):
    """ This function returns a Pyramid WSGI application.
    """
    authentication_policy = AuthTktAuthenticationPolicy('seekrit', callback=groupfinder)
    authorization_policy = ACLAuthorizationPolicy()

    engine = engine_from_config(settings, prefix='sqlalchemy.')
    db_maker = sessionmaker(bind=engine)
    settings['rel_db.sessionmaker'] = db_maker

    config = Configurator(settings=settings,
                          root_factory='scielobooks.resources.RootFactory',
                          authentication_policy=authentication_policy,
                          authorization_policy=authorization_policy,
                          request_factory=MyRequest,
                          renderer_globals_factory=renderer_globals_factory)

    config.include(pyramid_zcml)
    config.load_zcml('configure.zcml')
    config.include('pyramid_mailer')
    config.include('pyramid_celery')

    config.registry['mailer'] = Mailer.from_settings(settings)
    config.registry['app_version'] = APP_VERSION

    db_uri = settings['db_uri']
    conn = couchdbkit.Server(db_uri)
    config.registry.settings['db_conn'] = conn
    config.add_subscriber(add_couch_db, NewRequest)

    config.scan('scielobooks.models')
    initialize_sql(engine)

    if settings['serve_static_files'] == 'true':
        config.add_static_view(name='static', path='static')
    config.add_static_view('deform_static', 'deform:static')
    config.add_static_view('/'.join((settings['db_uri'], settings['db_name'])), 'scielobooks:database')
    config.add_static_view(settings['fileserver_url'], 'scielobooks:fileserver')

    config.add_view(custom_forbidden_view, context=Forbidden)

    config.add_translation_dirs('scielobooks:locale/')
    config.set_locale_negotiator(custom_locale_negotiator)

    my_session_factory = UnencryptedCookieSessionFactoryConfig('itsaseekreet')
    config.set_session_factory(my_session_factory)

    application = config.make_wsgi_app()

    try:
        if settings.get('newrelic.enable', 'False').lower() == 'true':
            newrelic.agent.initialize(os.path.join(APP_PATH, '..', 'newrelic.ini'), settings['newrelic.environment'])
            return newrelic.agent.wsgi_application()(application)
        else:
            return application
    except IOError:
        config.registry.settings['newrelic.enable'] = False
        return application
开发者ID:fabiobatalha,项目名称:scielobooks,代码行数:60,代码来源:__init__.py

示例5: main

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import load_zcml [as 别名]
def main(global_config, **settings):
    """Sets up the pyramid application.
    """
    config = Configurator(settings=settings)
    config.include(pyramid_zcml)
    config.hook_zca()
    config.load_zcml('configure.zcml')

    return config.make_wsgi_app()
开发者ID:4teamwork,项目名称:ftw.bridge.proxy,代码行数:11,代码来源:__init__.py

示例6: main

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

#    get_root = appmaker(engine)
    config = Configurator(settings=settings, root_factory=root_factory)
    zcml_file = settings.get('configure_zcml', 'configure.zcml')
    config.load_zcml(zcml_file)

    return config.make_wsgi_app()
开发者ID:boothead,项目名称:qtvis,代码行数:12,代码来源:__init__.py

示例7: main

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import load_zcml [as 别名]
def main(_, **settings):
    """ This function returns a Pyramid WSGI application.
    """
    engine = engine_from_config(settings, 'sqlalchemy.')
    lass.model_base.DBSession.configure(bind=engine)
    lass.model_base.Base.metadata.bind = engine
    config = Configurator(settings=settings)
    config.include('pyramid_zcml')
    config.load_zcml('config.global:configure.zcml')
    return config.make_wsgi_app()
开发者ID:UniversityRadioYork,项目名称:lass-pyramid,代码行数:12,代码来源:__init__.py

示例8: main

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import load_zcml [as 别名]
def main(global_config, **settings):
    """ This function returns a Pyramid WSGI application.
    """
    engine = engine_from_config(settings, 'sqlalchemy.')
    initialize_sql(engine)
    config = Configurator(settings=settings)
    config.include(pyramid_zcml)
    config.load_zcml('configure.zcml')
    config.set_session_factory(session_factory_from_settings(settings))
    return config.make_wsgi_app()
开发者ID:verkkodemokratiaseura,项目名称:verkkovaali,代码行数:12,代码来源:run.py

示例9: main

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import load_zcml [as 别名]
def main(global_config, **settings):
    root = settings.pop('root', None)
    if root is None:
        raise ValueError('virginia requires a root')
    fs = Filesystem(os.path.abspath(os.path.normpath(root)))
    def get_root(environ):
        return Directory(fs, root)
    config = Configurator(root_factory=get_root, settings=settings)
    config.include('pyramid_zcml')
    config.load_zcml('virginia:configure.zcml')
    return config.make_wsgi_app()
开发者ID:Stackato-Apps,项目名称:pyramid-virginia,代码行数:13,代码来源:__init__.py

示例10: make_app

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import load_zcml [as 别名]
def make_app(root_factory, package=None, filename='configure.zcml',
             settings=None, options=None, Configurator=Configurator):
    """ Return a Router object, representing a fully configured
    Pyramid WSGI application.

    .. warning:: Use of this function is deprecated as of
       Pyramid 1.0.  You should instead use a
       :class:`pyramid.config.Configurator` instance to
       perform startup configuration as shown in
       :ref:`configuration_narr`.

    ``root_factory`` must be a callable that accepts a :term:`request`
    object and which returns a traversal root object.  The traversal
    root returned by the root factory is the *default* traversal root;
    it can be overridden on a per-view basis.  ``root_factory`` may be
    ``None``, in which case a 'default default' traversal root is
    used.

    ``package`` is a Python :term:`package` or module representing the
    application's package.  It is optional, defaulting to ``None``.
    ``package`` may be ``None``.  If ``package`` is ``None``, the
    ``filename`` passed or the value in the ``options`` dictionary
    named ``configure_zcml`` must be a) absolute pathname to a
    :term:`ZCML` file that represents the application's configuration
    *or* b) a :term:`asset specification` to a :term:`ZCML` file in
    the form ``dotted.package.name:relative/file/path.zcml``.

    ``filename`` is the filesystem path to a ZCML file (optionally
    relative to the package path) that should be parsed to create the
    application registry.  It defaults to ``configure.zcml``.  It can
    also be a ;term:`asset specification` in the form
    ``dotted_package_name:relative/file/path.zcml``. Note that if any
    value for ``configure_zcml`` is passed within the ``settings``
    dictionary, the value passed as ``filename`` will be ignored,
    replaced with the ``configure_zcml`` value.

    ``settings``, if used, should be a dictionary containing runtime
    settings (e.g. the key/value pairs in an app section of a
    PasteDeploy file), with each key representing the option and the
    key's value representing the specific option value,
    e.g. ``{'reload_templates':True}``.  Note that the keyword
    parameter ``options`` is a backwards compatibility alias for the
    ``settings`` keyword parameter.
    """
    settings = settings or options or {}
    zcml_file = settings.get('configure_zcml', filename)
    config = Configurator(package=package, settings=settings,
                          root_factory=root_factory, autocommit=True)
    config.include(includeme)
    config.hook_zca()
    config.begin()
    config.load_zcml(zcml_file)
    config.end()
    return config.make_wsgi_app()
开发者ID:nak,项目名称:Penumbra,代码行数:56,代码来源:__init__.py

示例11: test_it

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import load_zcml [as 别名]
 def test_it(self):
     # see http://www.mail-archive.com/[email protected]/msg35171.html
     # for an explanation of why load_zcml of includeoverrideapp's
     # configure.zcml should raise a ConfigurationConflictError
     from pyramid.exceptions import ConfigurationConflictError
     from pyramid_zcml import includeme
     from pyramid.config import Configurator
     config = Configurator()
     config.include(includeme)
     config.load_zcml(self.config)
     self.assertRaises(ConfigurationConflictError, config.make_wsgi_app)
开发者ID:Pylons,项目名称:pyramid_zcml,代码行数:13,代码来源:test_integration.py

示例12: _registerComponents

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import load_zcml [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

示例13: main

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import load_zcml [as 别名]
def main(global_config, **settings):
    """ This function returns a Pyramid WSGI application.
    """
    zcml_file = settings.get('configure_zcml', 'configure.zcml')
    config = Configurator(root_factory=Root, settings=settings)
    config.include('pyramid_zcml')
    config.load_zcml(zcml_file)
    
    config.add_translation_dirs('scieloweb:locale/')
    config.set_locale_negotiator(custom_locale_negotiator)
    
    return config.make_wsgi_app()
开发者ID:fabiobatalha,项目名称:CouchDB-Web,代码行数:14,代码来源:__init__.py

示例14: zcml_configure

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import load_zcml [as 别名]
def zcml_configure(name, package):
    """ Given a ZCML filename as ``name`` and a Python package as
    ``package`` which the filename should be relative to, load the
    ZCML into the current ZCML registry.

    """
    registry = get_current_registry()
    configurator = Configurator(registry=registry, package=package)
    configurator.load_zcml(name)
    actions = configurator._ctx.actions[:]
    configurator.commit()
    return actions
开发者ID:csenger,项目名称:pyramid,代码行数:14,代码来源:zcml.py

示例15: setUp

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import load_zcml [as 别名]
 def setUp(self):
     from pyramid_zcml import includeme
     from pyramid.config import Configurator
     config = Configurator(root_factory=self.root_factory)
     config.include(includeme)
     config.begin()
     config.load_zcml(self.config)
     config.commit()
     app = config.make_wsgi_app()
     from webtest import TestApp
     self.testapp = TestApp(app)
     self.config = config
开发者ID:nak,项目名称:Penumbra,代码行数:14,代码来源:test_integration.py


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