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


Python pyramid_beaker.set_cache_regions_from_settings函数代码示例

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


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

示例1: main

def main(global_config, **settings):
    """ This function returns a Pyramid WSGI application.
    """
    set_cache_regions_from_settings(settings)
    config = Configurator(settings=settings)
    add_directives(config)
    authn_policy = BasicAuthAuthenticationPolicy(check=auth_check_func)
    authz_policy = ACLAuthorizationPolicy()
    config.set_authentication_policy(authn_policy)
    config.set_authorization_policy(authz_policy)
    config.add_static_view('static', 'static', cache_max_age=3600)
    config.add_route('browse', '/browse')
    config.add_route('simple', '/simple*traverse', factory=repository_root_factory)
    config.add_notfound_view(notfound, append_slash=True)
    config.add_jinja2_extension('webassets.ext.jinja2.AssetsExtension')
    assets_env = config.get_webassets_env()
    config.commit()
    jinja2_env = config.get_jinja2_environment()
    jinja2_env.assets_environment = assets_env
    # config.add_webasset('test', jst)
    config.add_webasset('papaye_js', papaye_js)
    config.add_webasset('papaye_css', papaye_css)
    config.add_webasset('papaye_font', papaye_font)
    config.check_database_config()
    config.scan()
    config.start_scheduler()
    return config.make_wsgi_app()
开发者ID:ldgeo,项目名称:papaye,代码行数:27,代码来源:__init__.py

示例2: main

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

示例3: main

def main(global_config, **settings):
    engine = engine_from_config(settings, 'sqlalchemy.')
    DBSession.configure(bind=engine)
    Base.metadata.bind = engine
    session_factory = session_factory_from_settings(settings)
    set_cache_regions_from_settings(settings)
    config = Configurator(settings=settings)
    config.set_session_factory(session_factory)
    config.include('pyramid_mako')
    #start_scheduler()
    config.add_static_view('static', 'static', cache_max_age=3600)
    config.add_static_view('data', 'data', cache_max_age=3600)
    config.add_route('home', '/')
    config.add_route('entities_list', '/entity/all')
    config.add_route('entities_table_json', '/entities/table/json')
    config.add_route('entities_table_page', '/entities/table')
    config.add_route('export_page', '/uik/export')
    config.add_route('entity', '/entity/{id}')
    config.add_route('register', '/register')
    config.add_route('logs', '/logs')

    config.add_route('entity_block', '/entity/block/{id}')
    config.add_route('entity_unblock', '/entity/unblock/{id}')

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

示例4: main

def main(global_config, **settings):
    """ This function returns a Pyramid WSGI application.
    """

    prepare_database(settings)

    authn_policy = AuthTktAuthenticationPolicy(
            'sikret;)', callback=groupfinder)
    authz_policy = ACLAuthorizationPolicy()
    config = Configurator(settings=settings,
        root_factory=RootFactory)
    config.set_authentication_policy(authn_policy)
    config.set_authorization_policy(authz_policy)

    config.set_default_permission('registered')

    config.include('pyramid_jinja2')
    config.include("pyramid_beaker")

    set_cache_regions_from_settings(settings)

    config.add_static_view('static', 'static', cache_max_age=3600)
    config.add_route('main', '/')
    config.add_route('login', '/login')
    config.add_route('logout', '/logout')
    config.add_route('engine.ajax', '/engine.ajax')
    config.scan()

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

示例5: main

def main(global_config, **settings):
    """ This function returns a WSGI application.
    """
    
    # all your authz and authn belong to us
    authn_policy = AuthTktAuthenticationPolicy('riotous4321',
                                                callback=groupfinder)
    authz_policy = ACLAuthorizationPolicy()
    
    # gimmie that Beaker session and region caching YO!
    session_factory = session_factory_from_settings(settings)
    set_cache_regions_from_settings(settings)
    
    # now make my app respect all of the stuff I just did
    config = Configurator(settings=settings,
                          root_factory=root_factory_maker(),
                          authentication_policy=authn_policy,
                          authorization_policy=authz_policy,
                          request_factory=RequestWithUserAttribute,
                          session_factory=session_factory)
    
    # setup the databasage
    engine = engine_from_config(settings, 'sqlalchemy.')
    config.scan('riotoustools.models')
    initialize_sql(engine)
                          
    # view_config + scan = win!
    config.add_static_view('static', 'riotoustools:static')
    config.scan('riotoustools.views')
    
    return config.make_wsgi_app()
开发者ID:wwitzel3,项目名称:riotoustools,代码行数:31,代码来源:__init__.py

示例6: main

def main(global_config, **settings):
    engine = engine_from_config(settings, 'sqlalchemy.')
    DBSession.configure(bind=engine)
    Base.metadata.bind = engine
    session_factory = session_factory_from_settings(settings)
    set_cache_regions_from_settings(settings)
    config = Configurator(settings=settings)
    config.set_session_factory(session_factory)
    start_scheduler()
    config.include('pyramid_mako')
    config.add_static_view('static', 'static', cache_max_age=3600)
    config.add_static_view('data', 'data', cache_max_age=3600)
    config.add_route('home', '/')
    config.add_route('uiks', '/uik/all')
    config.add_route('stat_json', '/uik/stat/json')
    config.add_route('statistic', '/uik/stat')
    config.add_route('uik_export_page', '/uik/export')
    config.add_route('uik', '/uik/{id}')
    config.add_route('uik_block', '/uik/block/{id}')
    config.add_route('uik_unblock', '/uik/unblock/{id}')
    config.add_route('uik_by_off_number', '/uik/{region_id}/{official_number}')
    config.add_route('register', '/register')
    config.add_route('logs', '/logs')
    config.add_route('uikp_all', '/uikp/all')
    config.add_route('uikp', '/uikp/{id}')
    config.scan()
    return config.make_wsgi_app()
开发者ID:nextgis,项目名称:uik_geo,代码行数:27,代码来源:__init__.py

示例7: setUp

    def setUp(self):
        self.workspace = self.mk_workspace()
        settings = self.get_settings(self.workspace, **{
            'unicorecomments.host': 'http://localhost/commentservice'})

        self.config = testing.setUp(settings=settings)
        self.config.include('cms')
        set_cache_regions_from_settings(settings)

        self.views = CmsViews(self.mk_request())
        self.app_id = settings['unicorehub.app_id']
        self.app = self.mk_app(self.workspace, settings=settings)

        [category] = self.create_categories(self.workspace, count=1)
        [page] = self.create_pages(
            self.workspace, count=1, description='description',
            primary_category=category.uuid)
        self.page = page
        self.stream = self.mk_comment_stream(
            page.uuid, state='open', offset=10, limit=5)

        self.patch_lazy_comment_page = mock.patch.object(
            LazyCommentPage, 'data',
            new=mock.PropertyMock(return_value=self.stream))
        self.patch_lazy_comment_page.start()
开发者ID:universalcore,项目名称:unicore-cms,代码行数:25,代码来源:test_comments.py

示例8: config

def config(request, pyramid_request, settings, registry):
    """ returns a Pyramid `Configurator` object initialized
        with Kotti's default (test) settings.
    """
    os.environ['TZ'] = "Europe/Paris"
    from pyramid_beaker import set_cache_regions_from_settings
    config = testing.setUp(
        registry=registry,
        settings=settings,
        request=pyramid_request
    )
    for include in settings['pyramid.includes'].split('\n'):
        include = include.strip()
        if include:
            config.include(include)
    set_cache_regions_from_settings(settings)
    request.addfinalizer(testing.tearDown)
    configure_filedepot(settings)

    from autonomie import setup_services, add_static_views
    setup_services(config, settings)
    add_static_views(config, settings)
    config.include('autonomie_celery')
    from autonomie.utils.renderer import customize_renderers
    customize_renderers(config)
    return config
开发者ID:CroissanceCommune,项目名称:autonomie,代码行数:26,代码来源:conftest.py

示例9: main

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

示例10: main

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

示例11: main

def main(global_config, **settings):
    """ This function returns a Pyramid WSGI application.
    """
    sessionFactory = session_factory_from_settings(settings)
    set_cache_regions_from_settings(settings)

    config = Configurator(settings=settings)
    config.set_session_factory(sessionFactory)

    get_current_registry().settings = settings

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

    config.add_route('home', '/')
    config.add_route('addContent', '/add')
    config.add_route('oneContent', '/{idContent}')
    config.add_route('oneContentRaw', '/{idContent}/raw')
    config.add_route('update', '/{idContent}/update')
    config.add_route('edit', '/{idContent}/edit')
    config.add_route('deleteConfirm', '/{idContent}/deleteConfirm')
    config.add_route('delete', '/{idContent}/delete')

    config.add_route('rss2', '/feeds/rss2')

    config.add_fanstatic_resources([resource.strip() for resource in settings['resources'].split(',')]
                                   , r'.*\.pt')

    config.scan()
    return config.make_wsgi_app()
开发者ID:Mika64,项目名称:paulla.paste,代码行数:29,代码来源:__init__.py

示例12: main

def main(global_config, **app_settings):
    """ This function returns a Pyramid WSGI application.
    """
    settings = global_config
    settings.update(app_settings)
    initialize_web_database(settings)
    session_factory = session_factory_from_settings(settings)
    auth_policy = AuthTktAuthenticationPolicy(
        settings['auth_tkt.secret'],
        callback=models.user.get_user_groups,
        hashalg='sha512',
    )
    set_cache_regions_from_settings(settings)
    config = Configurator(settings=settings,
                          request_factory=NDRequest,
                          session_factory=session_factory,
                          root_factory=_rsr.Root,
                          authentication_policy=auth_policy)

    config.include('pyramid_mako')
    config.include('pyramid_layout')

    config.include('notification_demo.lib.client_script')
    config.include("pyramid_vgid_oauth2")
    config.include("notification_demo.views")
    config.include("notification_demo.lib.notification")

    config.add_static_view('static', STATIC_DIR, cache_max_age=3600)
    config.add_route('home', '/')
    config.scan()
    return config.make_wsgi_app()
开发者ID:phamthanhnhan14,项目名称:noti_copy,代码行数:31,代码来源:__init__.py

示例13: main

def main(global_config, **settings):
    """ This function returns a Pyramid WSGI application.
    """
    initialize_sql(settings)
    
    session_factory = session_factory_from_settings(settings)
    set_cache_regions_from_settings(settings) 
    
    authentication_policy = AuthTktAuthenticationPolicy('somesecret')
    authorization_policy = ACLAuthorizationPolicy()
 
    config = Configurator(
        settings=settings, 
        session_factory=session_factory,
        authentication_policy=authentication_policy,
        authorization_policy=authorization_policy
    )
    
    config.add_subscriber(add_renderer_globals, BeforeRender)
    config.add_subscriber(csrf_validation, NewRequest)    
    
    
    config.add_mako_renderer(".html")

    config.add_static_view("static", "patchman:static", cache_max_age=3600)
    config.add_static_view("store",settings["storage"], cache_max_age=3600)
    
    MyRoutes(config)
      
    config.scan()
    return config.make_wsgi_app()
开发者ID:ricardosiri68,项目名称:patchcap,代码行数:31,代码来源:__init__.py

示例14: main

def main(global_config, **settings):
    """ This function returns a Pyramid WSGI application.
    """
    sessionFactory = session_factory_from_settings(settings)
    set_cache_regions_from_settings(settings)

    config = Configurator(settings=settings)

    config.include('pyramid_fanstatic')
    config.include('pyramid_beaker')
    config.include('pyramid_rawes')
    config.include('rebecca.fanstatic')

    config.set_session_factory(sessionFactory)

    settings['ES'] = config.get_rawes()
    get_current_registry().settings = settings

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

    config.add_route('home', '/')
    config.add_route('addContent', '/addContent')
    config.add_route('content', '/content/{imgID}')
    config.add_route('image', '/image/{imgID}')

    # print settings['resources'].split(',')
    # print [resource.strip() for resource in settings['resources'].split(',')]

    config.add_fanstatic_resources([resource.strip() for resource in settings['resources'].split(',')], r'.*\.pt')
    config.scan()
    return config.make_wsgi_app()
开发者ID:cyplp,项目名称:wtm,代码行数:31,代码来源:__init__.py

示例15: test_add_cache_multiple_region

    def test_add_cache_multiple_region(self):
        from pyramid_beaker import set_cache_regions_from_settings
        import beaker
        settings = self._set_settings()
        beaker.cache.cache_regions = {}
        settings['cache.regions'] = 'default_term, short_term'
        settings['cache.lock_dir'] = 'foo'
        settings['cache.short_term.expire'] = '60'
        settings['cache.default_term.type'] = 'file'
        settings['cache.default_term.expire'] = '300'
        settings['cache.default_term.enabled'] = 'false'
        set_cache_regions_from_settings(settings)
        default_term = beaker.cache.cache_regions.get('default_term')
        short_term = beaker.cache.cache_regions.get('short_term')
        self.assertEqual(short_term.get('expire'),
                         int(settings['cache.short_term.expire']))
        self.assertEqual(short_term.get('lock_dir'), settings['cache.lock_dir'])
        self.assertEqual(short_term.get('type'), 'memory')
        self.assertTrue(short_term.get('enabled'))

        self.assertEqual(default_term.get('expire'),
                         int(settings['cache.default_term.expire']))
        self.assertEqual(default_term.get('lock_dir'),
                         settings['cache.lock_dir'])
        self.assertEqual(default_term.get('type'),
                         settings['cache.default_term.type'])
        self.assertFalse(default_term.get('enabled'))
开发者ID:Mondego,项目名称:pyreco,代码行数:27,代码来源:allPythonContent.py


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