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


Python Configurator.scan方法代码示例

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


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

示例1: main

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import scan [as 别名]
def main(global_config, **settings):
    """ This function returns a Pyramid WSGI application.
    """
    engine = engine_from_config(settings, 'sqlalchemy.')
    DBSession.configure(bind=engine)

    Base.metadata.bind = engine

    session_factory = session_factory_from_settings(settings)

    authn_policy = AuthTktAuthenticationPolicy('s0secret', callback=groupfinder, hashalg='md5')
    #authn_policy = AuthTktAuthenticationPolicy('s0secret')
    authz_policy = ACLAuthorizationPolicy()

    config = Configurator(
        settings=settings,
        root_factory=RootFactory,
        authentication_policy=authn_policy,
        authorization_policy=authz_policy,
        session_factory=session_factory
        )

    # since version 1.5 templating is not included by default
    config.include('pyramid_chameleon')
    config.add_static_view('static', 'static', cache_max_age=3600)
    config.include(addroutes)
    config.scan()

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

示例2: main

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import scan [as 别名]
def main(global_config, **settings):
    """ This function returns a Pyramid WSGI application.
    """
    engine = engine_from_config(settings, 'sqlalchemy.')
    DBSession.configure(bind=engine)
    Base.metadata.bind = engine
    config = Configurator(settings=settings)
    config.add_static_view('static', 'static', cache_max_age=3600)

    config.add_route('index', '/')
    config.add_route('drink_page', '/drink/{item_id}')
    config.add_route('user_redirect', '/user')
    config.add_route('user_page', '/user/{username}')
    config.add_route('machine_page', '/machine/{machine_id}')
    config.add_route('autocomplete', '/autocomplete')
    config.add_route('drink_redirect', '/fordrink')

    config.add_route('api_item_usage', '/api/drink/{item_id}')
    config.add_route('api_user_usage', '/api/user/{username}')
    config.add_route('api_machine_usage', '/api/machine/{machine_id}')
    config.add_route('api_total_usage', '/api/total')
    config.add_route('api_pop_hours', '/api/hours')

    config.scan()
    return config.make_wsgi_app()
开发者ID:ComputerScienceHouse,项目名称:drink_stats_v2,代码行数:27,代码来源:__init__.py

示例3: main

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import scan [as 别名]
def main(global_config, **settings):
    config = Configurator(settings=settings)
    config.include("cornice")
    config.scan("corniceapp.views")
    if settings.get('database.url', None):
        db_url = settings.get('database.url')
    return config.make_wsgi_app()
开发者ID:ryansb,项目名称:openshift-cornice-oncogs,代码行数:9,代码来源:__init__.py

示例4: main

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import scan [as 别名]
def main(global_config, **settings):
    """ This function returns a Pyramid WSGI application.
    """
    settings['sqlalchemy.url'] = settings['cn.dialect'] + quote_plus(settings['sqlalchemy.url'])
    engine = engine_from_config(settings, 'sqlalchemy.')
    dbConfig['url'] = settings['sqlalchemy.url']
    
    DBSession.configure(bind=engine)
    Base.metadata.bind = engine
    Base.metadata.create_all(engine)
    Base.metadata.reflect(views=True, extend_existing=False)

    config = Configurator(settings=settings)
    # Add renderer for datetime objects
    json_renderer = JSON()
    json_renderer.add_adapter(datetime, datetime_adapter)
    json_renderer.add_adapter(Decimal, decimal_adapter)
    json_renderer.add_adapter(bytes, bytes_adapter)
    config.add_renderer('json', json_renderer)

    # Set up authentication and authorization
    includeme(config)
 #   config.set_root_factory(SecurityRoot)

    # config.set_request_factory(request_factory)
    config.add_subscriber(add_cors_headers_response_callback, NewRequest)
    # Set the default permission level to 'read'
    config.set_default_permission('read')
    config.include('pyramid_tm')
    add_routes(config)
    config.scan()
    return config.make_wsgi_app()
开发者ID:gerald13,项目名称:NSLog,代码行数:34,代码来源:__init__.py

示例5: main

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import scan [as 别名]
def main(global_config, **settings):
    """ This function returns a Pyramid WSGI application.
    """
    engine = engine_from_config(settings, 'sqlalchemy.')
    DBSession.configure(bind=engine)
    authn_policy = AuthTktAuthenticationPolicy(
        'sosecret', callback=groupfinder, hashalg='sha512')
    authz_policy = ACLAuthorizationPolicy()

    session_factory = session_factory = session_factory_from_settings(settings)

    config = Configurator(settings=settings,
                          root_factory='.models.RootFactory',
                          session_factory=session_factory)
    config.set_authentication_policy(authn_policy)
    config.set_authorization_policy(authz_policy)

    # Routes
    config.add_static_view('static', 'static', cache_max_age=3600)
    config.add_route('home_page', '/')
    config.add_route('login', '/login')
    config.add_route('logout', '/logout')

    # Admin
    config.add_route('admin_list_users', '/admin/users')
    config.add_route('admin_create_user', '/admin/users/create')
    config.add_route('admin_delete_user', '/admin/user/delete/{id}')
    config.add_route('admin_list_teams', '/admin/teams')
    config.add_route('admin_create_team', '/admin/teams/create')
    config.add_route('admin_delete_team', '/admin/teams/delete/{id}')

    config.scan()
    return config.make_wsgi_app()
开发者ID:makewhatis,项目名称:creme-fraiche,代码行数:35,代码来源:__init__.py

示例6: main

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

    config = Configurator(settings=settings)

    config.include('pyramid_jinja2')
    config.include('pyramid_tm')
    config.include('pyramid_exclog')
    config.include('pyramid_persona')
    config.include('cornice')

    # prevent conflicts with persona
    # and beaker/photoapp config

    config.commit()

    config.include('pyramid_beaker')

    # my stuff
    config.include('photoapp.models')
    config.include('photoapp.storage')
    config.include('photoapp.auth')
    config.include('photoapp.mail')
    config.include('photoapp.assets')
    config.include('photoapp.routes')
    config.include('photoapp.tweens')

    # caching
    set_cache_regions_from_settings(settings)

    config.scan()

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

示例7: main

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import scan [as 别名]
def main(global_settings, **settings):
    authn_policy = AuthTktAuthenticationPolicy(
        settings['auth.secret'],
    )
    authz_policy = ACLAuthorizationPolicy()

    config = Configurator(
        settings=settings,
        authentication_policy=authn_policy,
        authorization_policy=authz_policy,
    )

    config.add_route('home', '/')
    config.add_route('login', '/login')
    config.add_route('logout', '/logout')

    config.add_route('users', '/users')
    config.add_route('user', '/user/{login}')

    config.add_route('pages', '/pages')
    config.add_route('create_page', '/create_page')
    config.add_route('page', '/page/{title}')
    config.add_route('edit_page', '/page/{title}/edit')

    config.scan(__name__)
    return config.make_wsgi_app()
开发者ID:GeorgeAppsFlyer,项目名称:pyramid_auth_demo,代码行数:28,代码来源:demo.py

示例8: main

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import scan [as 别名]
def main(global_config, **settings):
    """ This function returns a Pyramid WSGI application.
    
    """
    # load app cfg
    app_cfg = load_app_cfg()
    settings.update(app_cfg)
    
    # setup database
    settings = setup_database(global_config, **settings)
    authentication_policy = AuthTktAuthenticationPolicy(
        secret=settings['auth_secret_key'],
        callback=get_group)
    authorization_policy = ACLAuthorizationPolicy()
    session_factory = session_factory_from_settings(settings)
    config = Configurator(settings=settings,
                          authentication_policy=authentication_policy,
                          authorization_policy=authorization_policy,
                          session_factory=session_factory,
                          request_factory=WebRequest)
    # activate translation
    config.add_translation_dirs('ez2pay:locale/')
    # add the mailer
    config.include('pyramid_mailer')
    if asbool(settings.get('use_dummy_mailer', False)):
        config.include('pyramid_mailer.testing')
    # add Genshi renderer
    config.include('pyramid_genshi')
    # setup modules
    config.include('.modules')
    # add static view
    config.add_static_view('static', 'ez2pay:static')
    # scan modules
    config.scan()
    return config.make_wsgi_app()
开发者ID:victorlin,项目名称:ez2pay,代码行数:37,代码来源:__init__.py

示例9: TestServiceDefinition

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

    def setUp(self):
        if not metlog:
            raise(unittest2.SkipTest('no metlog'))
        mozconfig = Config(StringIO(dedent("""
        [test1]
        backend = mozsvc.metrics.MetlogPlugin
        sender_class=metlog.senders.DebugCaptureSender
        """)))
        settings = {"config": mozconfig}
        self.plugin = load_from_config("test1", mozconfig)
        self.config = Configurator(settings=settings)
        self.config.include("cornice")
        self.config.scan("mozsvc.tests.test_service_definition")
        self.app = TestApp(CatchErrors(self.config.make_wsgi_app()))

    def tearDown(self):
        testing.tearDown()

    def test_decorated_view_fn(self):
        # passing a decorator in to the service api call should result in a
        # decorated view callable
        resp = self.app.get("/service3")
        self.assertEquals(resp.json, {'test': 'succeeded', 'wrapped0': 'yes'})

    def test_stacked_decorated_view(self):
        # passing a decorator in to the service api call should result in a
        # decorated view callable, ordering of the particular decorators
        # shouldn't break things
        resp = self.app.get("/service4")
        self.assertEquals(resp.json, {'test': 'succeeded', 'wrapped0': 'yes'})

        resp = self.app.get("/service5")
        self.assertEquals(resp.json, {'test': 'succeeded', 'wrapped0': 'yes'})
开发者ID:ncalexan,项目名称:mozservices,代码行数:37,代码来源:test_service_definition.py

示例10: main

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

    # Session
    session_factory = UnencryptedCookieSessionFactoryConfig('necronomicon')

    for option in ('server', 'client_id', 'client_secret', 'google_analytics'):
        key = 'yith_' + option
        settings[key] = read_setting_from_env(settings, key)

    settings['yith_debug'] = asbool(read_setting_from_env(settings, 'yith_debug'))

    config = Configurator(settings=settings, session_factory=session_factory)
    config.add_static_view('static', 'static', cache_max_age=3600)

    # Routes
    config.add_route('index', '/')
    config.add_route('oauth2cb', '/oauth2cb')
    config.add_route('token', '/token')
    config.add_route('list', '/list')
    config.add_route('logout', '/logout')
    config.add_route('tos', '/tos')

    config.scan()
    return config.make_wsgi_app()
开发者ID:srus,项目名称:yith-library-web-client,代码行数:28,代码来源:__init__.py

示例11: main

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

    config.begin()
        
    config.scan('sawhoosh.model')    
    initialize_sql(engine)
    
    config.add_route('index', '')
    config.add_route('search', '/search')
    
    config.add_route('author_new', '/author/new')
    config.add_route('author_edit', '/author/{id}/edit')
    config.add_route('author_instance', pattern='/author/{id}')
    config.add_route('author', pattern='/author')
    
    config.add_route('document_new', '/document/new')
    config.add_route('document_edit', '/document/{id}/edit')
    config.add_route('document_instance', pattern='/document/{id}')
    config.add_route('document', pattern='/document')
     
    config.add_static_view('static', 'sawhoosh:static')
    config.scan('sawhoosh.views')
    
    config.end()
    return HttpMethodOverrideMiddleware(config.make_wsgi_app())
开发者ID:theresia,项目名称:sawhoosh,代码行数:35,代码来源:__init__.py

示例12: main

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import scan [as 别名]
def main(global_config, **settings):
    """ This function returns a Pyramid WSGI application. """
    engine = engine_from_config(settings, 'sqlalchemy.')
    DBSession.configure(bind=engine)
    session_factory = session_factory_from_settings(settings)
    set_cache_regions_from_settings(settings)
    config = Configurator(settings=settings, session_factory=session_factory)
    config.set_authentication_policy(AuthTktAuthenticationPolicy(
            settings['authtkt.secret']))
    config.set_authorization_policy(ACLAuthorizationPolicy())
    config.add_static_view('static', 'static', cache_max_age=3600)
    config.add_route('home', '/')
    config.add_route('submit', '/submit')
    config.add_route('details', '/details')
    config.add_route('admin', '/admin')
    config.add_route('csv', '/csv')
    config.add_route('approve', '/approve')
    config.add_route('accept', '/accept')
    config.add_route('save_address', '/save_address')
    config.include('pyramid_mailer')
    config.add_route('login', '/login')
    config.add_route('logout', '/logout')
    config.add_view('fedorasummerofhardware.views.login_view',
                    renderer='fedorasummerofhardware:templates/login.mak',
                    context=Forbidden)
    config.scan()
    return config.make_wsgi_app()
开发者ID:fedora-infra,项目名称:fedora-openhw2012,代码行数:29,代码来源:__init__.py

示例13: main

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import scan [as 别名]
def main(global_config, **settings):
    """ This function returns a Pyramid WSGI application.
    """
    config_path = global_config['__file__']
    config = configparser.ConfigParser()
    config.read(config_path)
    mode = config.get('app:main','mode')
    print (mode)
    InitSetting(mode)
    #db_url = config.get('app:main', 'sqlalchemy.url')
    config = Configurator(settings=settings)
    config.include('pyramid_chameleon')
    config.add_static_view(name='static', path= 'static', cache_max_age=0)
    config.add_static_view(name='website', path= '../website', cache_max_age=0)
  
    config.add_route('test', '/test')
    config.add_route('home', '/')
    
  
    config.add_route('UpdateNews','/UpdateNews')
    config.add_route('ExtractNews','/ExtractNews')
    config.add_route('inn','/inn/{one}/{two}')
    
    config.add_route('SignUp','/SignUp')
    config.add_route('SignIn','/SignIn')
    config.add_route('LogOut','/LogOut') 
  
    
    ys_session_factory = SignedCookieSessionFactory("thisissecretkay")
    config.set_session_factory(ys_session_factory)

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

示例14: main

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import scan [as 别名]
def main(config, **settings):
    """ This function returns a Pyramid WSGI application.
    """
    config = Configurator(settings=settings)
    config.include("pypicloud")
    config.scan("pypicloud.views")
    return config.make_wsgi_app()
开发者ID:mathcamp,项目名称:pypicloud,代码行数:9,代码来源:__init__.py

示例15: createWsgiApp

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import scan [as 别名]
def createWsgiApp(global_config, debug=False, **settings):
    
    # first of all load the loggers
    loadLogger(debug)
    
    if debug:
        settings = {}
        settings['reload_all'] = True
        settings['debug_all'] = True
        
    LOGGER.info('Loading Configurator ...')
    config = Configurator(settings=settings)

    LOGGER.info('Include pyramid_tm ...')
    config.include('pyramid_tm')
    
    LOGGER.info('Loading database settings in ...')
    loadDB(config, settings, debug)

    # add routes
    LOGGER.info('Initialize routes ...')
    addRoutes(config)
    
    # add views to routes
    LOGGER.info('Add views (route endpoints) ...')
    config.scan('views')
    
    LOGGER.info('Georeference rest application is initialize.')
    return config.make_wsgi_app()
开发者ID:zuphilip,项目名称:vk2-georeference,代码行数:31,代码来源:__init__.py


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