• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python pyramid_beaker.set_cache_regions_from_settings函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


示例16: main

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

    initialize_db(settings)
    configure(settings)

    # set beaker cache region
    set_cache_regions_from_settings(settings)
    config = Configurator(settings=settings, root_factory=RootFactory)

    # include edauth. Calls includeme
    config.include(edauth)
    # Pass edauth the roles/permission mapping that is defined in hpz
    edauth.set_roles(RootFactory.__acl__)

    # include add routes from frs. Calls includeme
    config.include(frs)
    config.include(swi)
    config.include(services)

    config.scan()

    # Clean up old files from HPZ
    run_cron_job(settings, HPZ_EXPIRATION + '.', cleanup)

    logger.info("HPZ Started")

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


示例17: main

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

    check_username = lambda username, password:\
        settings['gmusicapi_username'] == username and\
        settings['gmusicapi_password'] == password
    if not gm.login(settings['gmusicapi_username'],
                    settings['gmusicapi_password']):
        logger.warn("Unable to login to Google Music!")
        exit()
    if not wc.login(settings['gmusicapi_username'],
                    settings['gmusicapi_password']):
        logger.warn("Unable to login to Google Music!")
        exit()

    engine = engine_from_config(settings, 'sqlalchemy.')
    DBSession.configure(bind=engine)
    Base.metadata.bind = engine
    set_cache_regions_from_settings(settings)
    config = Configurator(settings=settings)
    config.include('pyramid_chameleon')
    config.include('gmusic.views')
    config.add_static_view('static', 'static', cache_max_age=3600)
    config.scan()
    return config.make_wsgi_app()
开发者ID:demophoon,项目名称:Google-Music-Party-Mode,代码行数:27,代码来源:__init__.py


示例18: main

def main(global_config, **settings):

  authn_policy = AuthTktAuthenticationPolicy('sosecret', callback=groupfinder)
  authz_policy = ACLAuthorizationPolicy()
  session_factory = session_factory_from_settings(settings)
  set_cache_regions_from_settings(settings)

  config = Configurator(
    settings=settings, 
    root_factory= 'innovation.models.RootFactory',
    authentication_policy=authn_policy,
    authorization_policy=authz_policy,
    session_factory=session_factory
  )  
  
  # Business owner / employee routes
  config.add_route('root', '/')
  config.add_route('login', '/login')
  config.add_route('logout', '/logout')
  config.add_route('add_employee', '/manage/employees/add')
  config.add_route('manage_employees', '/manage/employees')
  config.add_route('manage_all', '/manage')
  config.add_route('manage', '/manage/{b_id}')
  config.add_route('get_queue', '/get_queue')
  config.add_route('remove_from_queue', '/remove')
  config.add_route('add_to_queue_manual', '/add_to_queue_manual')
  config.add_route('notify_user', '/notify_user')
  config.add_route('check_in', '/check_in')
  config.add_route('check_out', '/check_out')

  # Admin routes
  config.add_route('admin_main', '/admin')
  config.add_route('admin_list_business', '/admin/business')
  config.add_route('admin_edit_business', '/admin/business/edit')
  config.add_route('admin_add_business', '/admin/business/add')
  config.add_route('admin_list_user', '/admin/user')
  config.add_route('admin_add_user', '/admin/user/add')
  config.add_route('admin_edit_user', '/admin/user/edit')
  #config.add_route('', '')

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

  # MongoDB
  def add_mongo_db(event):
        settings = event.request.registry.settings
        url = settings['mongodb.url']
        db_name = settings['mongodb.db_name']
        db = settings['mongodb_conn'][db_name]
        event.request.db = db
  db_uri = settings['mongodb.url']
  MongoDB = pymongo.Connection
  if 'pyramid_debugtoolbar' in set(settings.values()):
        class MongoDB(pymongo.Connection):
            def __html__(self):
                return 'MongoDB: <b>{}></b>'.format(self)
  conn = MongoDB(db_uri)
  config.registry.settings['mongodb_conn'] = conn
  config.add_subscriber(add_mongo_db, NewRequest)
  config.scan('innovation')
  return config.make_wsgi_app()
开发者ID:winning100,项目名称:NQueueServer,代码行数:60,代码来源:__init__.py


示例19: test_add_cache_no_regions

 def test_add_cache_no_regions(self):
     from pyramid_beaker import set_cache_regions_from_settings
     import beaker
     settings = self._set_settings()
     beaker.cache.cache_regions = {}
     settings['cache.regions'] = ''
     set_cache_regions_from_settings(settings)
     self.assertEqual(beaker.cache.cache_regions, {})
开发者ID:Mondego,项目名称:pyreco,代码行数:8,代码来源:allPythonContent.py


示例20: main

def main(global_config, **settings):
    """ This function returns a Pyramid WSGI application.
    """
    set_cache_regions_from_settings(settings)
    config = Configurator(settings=settings)
    config.include('cms')
    config.configure_celery(global_config['__file__'])
    return config.make_wsgi_app()
开发者ID:universalcore,项目名称:unicore-cms,代码行数:8,代码来源:__init__.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python compat.bytes_函数代码示例发布时间:2022-05-27
下一篇:
Python pyramid_beaker.session_factory_from_settings函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap