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


Python Configurator.add_settings方法代码示例

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


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

示例1: setup

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import add_settings [as 别名]
    def setup(self, failure_code=None):
        from pyramid_health import HealthCheckEvent

        self.check1_status = 'OK'
        self.check1_message = 'report1'

        def check1(event):
            event.report(name='check1',
                         status=self.check1_status,
                         message=self.check1_message)

        self.check2_status = 'OK'
        self.check2_message = 'report2'

        def check2(event):
            event.report(name='check2',
                         status=self.check2_status,
                         message=self.check2_message)
        config = Configurator()
        if failure_code is not None:
            config.add_settings({'healthcheck.failure_code': failure_code})
        config.include('pyramid_health')
        config.add_subscriber(check1, HealthCheckEvent)
        config.add_subscriber(check2, HealthCheckEvent)

        self.app = webtest.TestApp(config.make_wsgi_app())
开发者ID:ludia,项目名称:pyramid_health,代码行数:28,代码来源:tests.py

示例2: main

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import add_settings [as 别名]
def main(global_config, **settings):
    """ This function returns a Pyramid WSGI application.
    """
    config = Configurator(settings=settings)
    settings = config.get_settings()
    # In case certain directories aren't set in the config, we can default to
    # making one in the same directory as the config file.
    config.add_settings({
        'config_path': os.path.dirname(global_config['__file__'])
    })
    session_factory = UnencryptedCookieSessionFactoryConfig(
        settings['session.secret']
    )
    config.set_session_factory(session_factory)
    config.include('pyramid_debugtoolbar')
    config.include('pyramid_mako')
    config.include('pyramid_dogpile_cache2')
    config.include('.db')
    config.include('.routes')
    # Instantiate Whoosh Search Index
    config.include('.lib.search')
    # Setup python-social-auth
    config.add_request_method(
        'chiplibrary.lib.auth.get_user',
        'user',
        reify=True
    )
    config.include('chiplibrary.lib.auth')
    init_social(config, Base, config.registry['dbsession_factory'])
    # Add subscribers to instantiate processes or run necessary startup tasks
    config.add_subscriber(add_renderer_globals, BeforeRender)
    config.add_subscriber(breadcrumb_subscriber, NewRequest)
    config.scan()
    config.scan('social_pyramid')
    return config.make_wsgi_app()
开发者ID:chrisrsantiago,项目名称:chiplibrary,代码行数:37,代码来源:__init__.py

示例3: main

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import add_settings [as 别名]
def main(global_config, **settings):
    """ This function returns a Pyramid WSGI application.
    """
    engine = engine_from_config(settings, 'sqlalchemy.', connect_args={'check_same_thread':False}, poolclass=StaticPool)
    initialize_sql(engine)
    # authentication_policy = SessionAuthenticationPolicy(callback=CheckPermissions)
    # authorization_policy = MyAuthorisationPolicy()
    session_factory = session_factory_from_settings(settings)
    ## caches

    ## end
    config = Configurator(settings=settings)
    config.set_session_factory(session_factory)

    config.add_settings({'cache.example': Cache(settings['cache.example'], 'example')})

    config.add_static_view('static', 'phdb:static')

    files = file_loader(config.get_settings()['links'], config.get_settings()['data_path'], True)
    files = ['/Users/vpol/PycharmProjects/phdb/phdb/data/Kody_ABC-3kh.csv', '/Users/vpol/PycharmProjects/phdb/phdb/data/Kody_ABC-4kh.csv',
             '/Users/vpol/PycharmProjects/phdb/phdb/data/Kody_ABC-8kh.csv', '/Users/vpol/PycharmProjects/phdb/phdb/data/Kody_DEF-9kh.csv']
    log.debug('in {0}: finished loading stage'.format(funcname()))
    dbload(files, False)
    log.debug('in {0}: finished db loading stage'.format(funcname()))
    ix = reindex(files, config.get_settings()['ix_path'], True)
    log.debug('in {0}: finished reindex stage'.format(funcname()))
    config.add_settings({'ix': ix})

    # Index (main page)
    config.add_route('index', '/')
    config.add_view('phdb.views.index', route_name = 'index', renderer='json')

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

示例4: registerSettings

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import add_settings [as 别名]
def registerSettings(dictarg=None, **kw):
    """Register one or more 'setting' key/value pairs.  A setting is
    a single key/value pair in the dictionary-ish object returned from
    the API :attr:`pyramid.registry.Registry.settings`.

    You may pass a dictionary::

       registerSettings({'external_uri':'http://example.com'})

    Or a set of key/value pairs::

       registerSettings(external_uri='http://example.com')

    Use of this function is required when you need to test code that calls
    the :attr:`pyramid.registry.Registry.settings` API and which uses return
    values from that API.

    .. warning:: This API is deprecated as of :app:`Pyramid` 1.0.
       Instead use the
       :meth:`pyramid.config.Configurator.add_settings`
       method in your unit and integration tests.
    """
    registry = get_current_registry()
    config = Configurator(registry=registry)
    config.add_settings(dictarg, **kw)
开发者ID:jkrebs,项目名称:pyramid,代码行数:27,代码来源:testing.py

示例5: main

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

    # TODO: make it safer. Remember it's unencrypted.
    my_session_factory = UnencryptedCookieSessionFactoryConfig('itsaseecreet')
    authn_policy = AuthTktAuthenticationPolicy(secret='sosecret',
                                               callback=groupfinder)
    authz_policy = ACLAuthorizationPolicy()
    config = Configurator(session_factory=my_session_factory,
                          root_factory=root_factory, settings=settings,
                          authentication_policy=authn_policy,
                          authorization_policy=authz_policy)
    config.add_translation_dirs('easyblog:locale/')
    config.set_locale_negotiator(my_locale_negotiator)
    config.add_settings(encoding="UTF-8")
    # config.add_settings(languages=['fi', 'en'])
    # config.add_settings({'default_locale_name': 'fi'})
    config.add_settings(default_encoding="UTF-8")
    config.hook_zca()

    config.include('pyramid_viewgroup')

    config.add_static_view('static', 'easyblog:static/', cache_max_age=3600)
    config.scan()

    config.add_route('lang', '/lang-{code}')
    return config.make_wsgi_app()
开发者ID:tojuhaka,项目名称:easyblog,代码行数:30,代码来源:__init__.py

示例6: main

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import add_settings [as 别名]
def main(global_config, config=None, **settings):
    if not config:
        config = Configurator(settings=settings, root_factory=RouteFactory)

    # Force project name, since it determines settings prefix.
    config.add_settings({'cliquet.project_name': 'kinto'})

    cliquet.initialize(config,
                       version=__version__,
                       default_settings=DEFAULT_SETTINGS)

    settings = config.get_settings()

    # In Kinto API 1.x, a default bucket is available.
    # Force its inclusion if not specified in settings.
    if 'kinto.plugins.default_bucket' not in settings['includes']:
        config.include('kinto.plugins.default_bucket')

    # Retro-compatibility with first Kinto clients.
    config.registry.public_settings.add('cliquet.batch_max_requests')

    # Scan Kinto views.
    kwargs = {}
    flush_enabled = asbool(settings.get('flush_endpoint_enabled'))
    if not flush_enabled:
        kwargs['ignore'] = 'kinto.views.flush'
    config.scan("kinto.views", **kwargs)

    app = config.make_wsgi_app()

    # Install middleware (idempotent if disabled)
    return cliquet.install_middlewares(app, settings)
开发者ID:iomedhealth,项目名称:kinto,代码行数:34,代码来源:__init__.py

示例7: main

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import add_settings [as 别名]
def main(global_config, **settings):
    """ This function returns a Pyramid WSGI application.
    """
    config = Configurator(settings=settings)
    config.registry.registerUtility(link_attrs, interfaces.ILinkAttrs)
    config.include('clldmpg')
    config.include('clld_glottologfamily_plugin')
    config.registry.registerUtility(MyMapMarker(), interfaces.IMapMarker)

    config.add_page('submit')
    config.add_page('help')
    config.register_menu(
        ('dataset', partial(menu_item, 'dataset', label='Home')),
        ('contributions', partial(menu_item, 'contributions')),
        ('parameters', partial(menu_item, 'parameters')),
        ('sentences', partial(menu_item, 'sentences')),
        ('help', lambda ctx, rq: (rq.route_url('help'), u'Help')),
    )

    config.add_settings(
        home_comp=['submit', 'contributors', 'languages'] +
        config.get_settings()['home_comp'])

    for cls in [md.BibTex, md.ReferenceManager]:
        for if_ in [interfaces.IRepresentation, interfaces.IMetadata]:
            config.register_adapter(cls, interfaces.IContribution, if_, name=cls.mimetype)

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

示例8: main

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import add_settings [as 别名]
def main(global_config, **settings):
    """ This function returns a Pyramid WSGI application.
    """
    LOG.debug("settings:{}".format(settings))
    engine = engine_from_config(settings, 'sqlalchemy.')
    DBSession.configure(bind=engine)
    Base.metadata.bind = engine
    config = Configurator(settings=settings)
    config.include('pyramid_chameleon')
    config.add_static_view('static', 'static', cache_max_age=3600)
    config.add_static_view('jasny-css', 'static/jasny-bootstrap/css', cache_max_age=3600)
    config.add_static_view('jasny-js', 'static/jasny-bootstrap/js', cache_max_age=3600)
    config.add_route('login', '/')
    config.add_route('logout', '/logout')
    config.add_route('show_empl', '/employee/{emp_no}',
                     factory=EmployeeRootFactory)
    config.add_route('show_dept', '/department/{dept_no}',
                     factory=DeptRootFactory)

    auth_engine = AuthEngine()
    config.add_settings(auth_engine=auth_engine)
    authn_policy = AuthTktAuthenticationPolicy(settings['secret_key'],
                                               callback=auth_engine.get_groups,
                                               hashalg='sha512')
    config.set_authentication_policy(authn_policy)
    config.set_authorization_policy(ACLAuthorizationPolicy())

    query_parser = FormQueryParser()
    config.add_settings(query_parser=query_parser)

    config.scan()

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

示例9: main

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

    It is usually called by the PasteDeploy framework during
    ``paster serve``.
    """
    settings = dict(settings)
    settings.setdefault('jinja2.i18n.domain', 'slack_mirror')

    config = Configurator(root_factory=RootFactory, settings=settings)
    maker = get_sessionmaker(settings)
    config.add_settings({'db.sessionmaker': maker})
    config.add_request_method(db, reify=True)

    config.add_translation_dirs('locale/')
    config.include('pyramid_jinja2')

    authn_policy = AuthTktAuthenticationPolicy(settings['tkt_secret'])
    config.set_authentication_policy(authn_policy)

    authz_policy = ACLAuthorizationPolicy()
    config.set_authorization_policy(authz_policy)

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

    config.add_route('home', '/')
    config.add_route('zulip_key', '/zulip_key')
    config.add_route('login', '/_login')
    config.add_route('logout', '/_logout')
    config.add_route('oauth2_callback', '/oauth2callback')
    config.add_route('start_mirror', '/start_mirror')
    config.add_route('stop_mirror', '/stop_mirror')
    config.scan()
    return config.make_wsgi_app()
开发者ID:armooo,项目名称:slack_mirror,代码行数:36,代码来源:__init__.py

示例10: main

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import add_settings [as 别名]
def main(global_config, **settings):
    """This function returns a Pyramid WSGI application."""
    engine = engine_from_config(settings, "sqlalchemy.")
    DBSession.configure(bind=engine)
    config = Configurator(settings=settings)
    config.add_settings(
        {"mako.imports": "from shoppinglist.filters import json"}
    )
    config.include("pyramid_mako")
    config.include("pyramid_tm")
    config.add_static_view("static", "static", cache_max_age=365*24*3600)
    config.add_cache_buster("static", ChecksumCacheBuster("static/SHA256SUMS"))
    config.add_route("home", "/")
    # Let's go nuts with REST, why don't we?
    config.add_route("list_items", "/api/items", request_method="GET")
    config.add_route("add_item", "/api/items", request_method="POST")
    config.add_route("remove_item", "/api/items/{id}", request_method="DELETE")
    config.add_route(
        "check_item", "/api/items/{id}/checked", request_method="POST"
    )
    config.add_route(
        "uncheck_item", "/api/items/{id}/checked", request_method="DELETE"
    )
    config.add_route("clear_list", "/api/items", request_method="DELETE")
    config.scan()
    return config.make_wsgi_app()
开发者ID:mgedmin,项目名称:ShoppingList,代码行数:28,代码来源:__init__.py

示例11: main

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import add_settings [as 别名]
def main(global_config, **settings):

    """ This function returns a Pyramid WSGI application.
    """
#    authn_policy = AuthTktAuthenticationPolicy(
#        'gabbleblotchits')
#    authz_policy = SNMAuthorizationPolicy()
    config = Configurator(
#        authentication_policy=authn_policy,
#        authorization_policy=authz_policy,
        settings=settings
        )

    config.include("pyramid_jinja2")
    config.commit()
    config.get_jinja2_environment().filters['epoch2readable'] = epoch2readable
    config.get_jinja2_environment().filters['duration'] = duration

    def addSettings(event):
        event["sci_platform"] = settings["sci_platform"]
        event["google_tracking_code"] = settings["google_tracking_code"]

    config.add_subscriber(addSettings, BeforeRender)

    # Configuring static assets
    config.add_static_view(name="static", path="static")

    config.add_settings({"sci_platform": settings["sci_platform"],
                         "google_tracking_code": settings["google_tracking_code"]})
    config.add_route("home", "/")
    config.add_route("dsm", "/dsm")

    config.add_route("app_used_with",   "/application/{name}/used_with")
    config.add_route("app_usage",       "/application/{name}/usage")
    config.add_route("app_users",       "/application/{name}/users")
    config.add_route("app_dashboard",   "/application/{name}/dashboard")
    config.add_route("application",     "/application/{name}")
    config.add_route("app_pubs",        "/application/{name}/publications")
    config.add_route("app_gitprojects", "/application/{name}/gitprojects")

    config.add_route("compare", "/compare")
    config.add_route("about", "/about")
    config.add_route("data_source", "/data_source")
    config.add_route("browse", "/browse")
    config.add_route("overview", "/overview")
    config.add_route("login", "/login")
    config.add_route("notebook", "/notebook")
    config.add_route("status", "/status")
    config.add_route("sys_usage",       "/status/usage")
    config.add_route("accept_login", "/accept_login")
    
    config.add_route("api_home", "/api")
    config.add_route("api_home.category", "/api/{category}")
    config.add_route("api_home.category.id", "/api/{category}/{id}")

    connect(settings['db_name'])
    register_connection('raw-records', settings['raw_db_name'])

    config.scan()
    return config.make_wsgi_app()
开发者ID:Medida-CMU,项目名称:scisoft-net-map,代码行数:62,代码来源:__init__.py

示例12: main

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import add_settings [as 别名]
def main(global_config, **settings):
    config = Configurator(settings=settings, root_factory=RouteFactory)

    # Force project name, since it determines settings prefix.
    config.add_settings({'cliquet.project_name': 'kinto'})

    cliquet.initialize(config,
                       version=__version__,
                       default_settings=DEFAULT_SETTINGS)

    # Redirect default to the right endpoint
    config.add_route('default_bucket_collection',
                     '/buckets/default/{subpath:.*}')
    config.add_route('default_bucket', '/buckets/default')

    # Retro-compatibility with first Kinto clients.
    config.registry.public_settings.add('cliquet.batch_max_requests')

    # Scan Kinto views.
    settings = config.get_settings()
    kwargs = {}
    flush_enabled = asbool(settings.get('flush_endpoint_enabled'))
    if not flush_enabled:
        kwargs['ignore'] = 'kinto.views.flush'
    config.scan("kinto.views", **kwargs)

    app = config.make_wsgi_app()

    # Install middleware (idempotent if disabled)
    return cliquet.install_middlewares(app, settings)
开发者ID:harman-red-square,项目名称:Kinto,代码行数:32,代码来源:__init__.py

示例13: main

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import add_settings [as 别名]
def main(global_config, config=None, **settings):
    if not config:
        config = Configurator(settings=settings, root_factory=RouteFactory)

    # Force project name, since it determines settings prefix.
    config.add_settings({"cliquet.project_name": "kinto"})

    cliquet.initialize(config, version=__version__, default_settings=DEFAULT_SETTINGS)

    # Redirect default to the right endpoint
    config.add_route("default_bucket_collection", "/buckets/default/{subpath:.*}")
    config.add_route("default_bucket", "/buckets/default")

    # Provide helpers
    config.add_request_method(default_bucket_id, reify=True)
    # Override Cliquet default user info
    config.add_request_method(get_user_info)

    # Retro-compatibility with first Kinto clients.
    config.registry.public_settings.add("cliquet.batch_max_requests")

    # Scan Kinto views.
    settings = config.get_settings()
    kwargs = {}
    flush_enabled = asbool(settings.get("flush_endpoint_enabled"))
    if not flush_enabled:
        kwargs["ignore"] = "kinto.views.flush"
    config.scan("kinto.views", **kwargs)

    app = config.make_wsgi_app()

    # Install middleware (idempotent if disabled)
    return cliquet.install_middlewares(app, settings)
开发者ID:is00hcw,项目名称:kinto,代码行数:35,代码来源:__init__.py

示例14: main

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import add_settings [as 别名]
def main(global_config, **settings):
    config = Configurator(settings=settings)

    cliquet.initialize(config, __version__, 'syncto',
                       default_settings=DEFAULT_SETTINGS)

    # Retro-compatibility with first Kinto clients.
    config.registry.public_settings.add('cliquet.batch_max_requests')

    settings = config.get_settings()
    config.registry.heartbeats['sync'] = ping_sync_cluster

    # For the use of a valid cache_hmac_secret key.
    if settings['cache_hmac_secret'] is None:
        error_msg = "Please configure the `syncto.cache_hmac_secret` settings."
        raise ValueError(error_msg)

    # Handle Certificate Pinning file.
    ca_bundle_path = settings['certificate_ca_bundle']
    if ca_bundle_path is not None:
        ca_bundle_abspath = os.path.abspath(ca_bundle_path)
        if not os.path.isfile(ca_bundle_abspath):
            error_msg = "File %s cannot be found." % ca_bundle_abspath
            raise ValueError(error_msg)

        config.add_settings({
            'certificate_ca_bundle': ca_bundle_abspath
        })

    config.scan("syncto.views")
    return config.make_wsgi_app()
开发者ID:mozilla-services,项目名称:syncto,代码行数:33,代码来源:__init__.py

示例15: app_config

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import add_settings [as 别名]
def app_config():
    config = Configurator(settings=load(open(SETTINGS_FILE, 'r').read()))
    config.add_settings({'currentapp.basedir': APP_BASE_DIR})
    config.add_translation_dirs('example_app:locale/')
    config.hook_zca()
    config.include('example_app')
    # config.add_route('catchall', '{notfound:.*}')
    return config
开发者ID:jarederaj,项目名称:pyramid-gae-tutorial,代码行数:10,代码来源:main.py


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