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


Python Configurator.add_jinja2_renderer方法代码示例

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


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

示例1: main

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import add_jinja2_renderer [as 别名]
def main(global_config, **settings):
    """ This function returns a WSGI application.
    
    It is usually called by the PasteDeploy framework during 
    ``paster serve``.
    """
    engine = engine_from_config(settings, 'sqlalchemy.')
    DBSession.configure(bind = engine)
    Base.metadata.bind = engine
    settings = dict(settings)
    settings.setdefault('jinja2.i18n.domain', 'blog')
    config = Configurator(settings=settings)
    #session set
    my_session_factory = SignedCookieSessionFactory('itsaseekreet')
    config.set_session_factory(my_session_factory)
    #session set end
    config.add_translation_dirs('locale/')
    config.include('pyramid_jinja2')
    config.add_jinja2_renderer('.html')
    config.add_static_view('static', 'static', cache_max_age = 3600)
    # config.add_view('blog.views.my_view',
    #                 context='blog.models.MyModel', 
    #                 renderer="templates/mytemplate.jinja2")
    config.add_route('view_blogs', '/view_blogs')
    config.add_route('edit_blog','/edit_blog/{blog_id}')
    config.add_route('add_blog', '/add_blog')
    config.add_route('signup','/signup')
    config.add_route('admin','/admin')
    config.add_route('validname', '/validname')
    config.add_route('signin','/signin')
    config.add_route('add_blogclass','/add_blogclass')
    config.add_route('get_blogclasses', '/get_blogclasses')
    config.scan()
    return config.make_wsgi_app()
开发者ID:shushuang,项目名称:noteblog,代码行数:36,代码来源:__init__.py

示例2: main

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

    # authentication_policy = AuthTktAuthenticationPolicy(
    #     AUTH_SECRET,
    #     callback=get_principal_indentifiers,
    # )
    # authorization_policy = ACLAuthorizationPolicy()

    config = Configurator(
        settings=settings,
    )

    config.add_static_view('static', 'static', cache_max_age=3600)
    config.add_static_view(name='media', path=MEDIA_ROOT, cache_max_age=3600)

    # Add .html extension as a renderer
    config.add_jinja2_renderer('.html')

    # Scan views for route configuration
    config.include('chitragupta.views.home')

    config.scan()

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

示例3: main

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import add_jinja2_renderer [as 别名]
def main(global_config, **settings):
    """ This function returns a Pyramid WSGI application.
    """
    # Auth system
    secret_key = settings.get('secret.key', 'secretkey')
    authentication_policy = AuthTktAuthenticationPolicy(secret_key, hashalg='sha512')
    authorization_policy = ACLAuthorizationPolicy()

    config = Configurator(settings=settings, authentication_policy=authentication_policy, authorization_policy=authorization_policy)
    config.set_default_permission('view')

    # Including packages
    config.include('pyramid_jinja2')
    config.include('.models')
    config.include('.views')

    # Configuring jinja2
    config.add_jinja2_search_path('jesusanaya_blog:templates/', name='.html')
    config.add_jinja2_renderer('.html', settings_prefix='jinja2.')

    config.add_static_view(name='static', path='jesusanaya_blog:static', cache_max_age=3600)
    config.add_request_method(request_static_method, 'static')

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

示例4: main

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import add_jinja2_renderer [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
    authn_policy = AuthTktAuthenticationPolicy(
        'sosecret', callback=groupfinder, hashalg='sha512')
    authz_policy = ACLAuthorizationPolicy()
    config = Configurator(settings=settings, root_factory='assetdb.models.RootFactory')
    config.set_authentication_policy(authn_policy)
    config.set_authorization_policy(authz_policy)
    config.include('pyramid_chameleon')
    config.include('pyramid_jinja2')
    config.add_jinja2_renderer('.html')
    config.add_static_view('static', 'static', cache_max_age=3600)
    config.add_route('index', '/')
    config.add_route('asset', '/asset')
    config.add_route('show_maker', '/maker')
    config.add_route('show_maker_detail', '/maker/{maker_id}')
    config.add_route('show_model_detail', '/model/{model_id}')
    config.add_route('show_asset_detail', '/asset/{asset_id}')
    config.add_route('get_maker', '/api/maker')
    config.add_route('get_maker_detail', '/api/maker/{maker_id}')
    config.add_route('get_model_detail', '/api/model/{model_id}')
    config.add_route('get_asset_detail', '/api/asset/{asset_id}')
    config.add_route('login', '/login')
    config.add_route('logout', '/logout')
    config.scan()
    return config.make_wsgi_app()
开发者ID:hichtakk,项目名称:asset,代码行数:32,代码来源:__init__.py

示例5: main

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import add_jinja2_renderer [as 别名]
def main(global_config, **settings):
    log.info(settings)
    log.info(global_config)
    engine = engine_from_config(settings, 'sqlalchemy.')
    Base.metadata.bind = engine
    config = Configurator(settings=settings)
    config.include('pyramid_jinja2')
    config.add_jinja2_renderer('.html')
    routes(config)
    app = config.make_wsgi_app()
    app = cookie_session(app)
    app = db_session_adder(app, engine)
    app = config_ware(app, config)
    return app
开发者ID:timtadh,项目名称:gitolite-manager,代码行数:16,代码来源:app.py

示例6: setup_wsgi

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import add_jinja2_renderer [as 别名]
def setup_wsgi():
    configurator = Configurator()

    configurator.include("pyramid_jinja2")
    configurator.add_jinja2_renderer('.html')
    configurator.add_jinja2_search_path('websauna.tests:templates/viewconfig', name='.html')

    configurator.add_route("parent_hello", "/parent_hello")
    configurator.add_route("child_hello", "/child_hello")

    from websauna.tests.viewconfig import testmodule
    configurator.set_root_factory(testmodule.Root)
    configurator.scan(testmodule)

    wsgi = TestApp(configurator.make_wsgi_app())
    return wsgi
开发者ID:arianmaykon,项目名称:websauna,代码行数:18,代码来源:test_viewconfig.py

示例7: main

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import add_jinja2_renderer [as 别名]
def main(global_config, **settings):
    """Return a Pyramid WSGI application."""
    engine = engine_from_config(settings, "sqlalchemy.")

    DBSession.configure(bind=engine)

    Base.metadata.bind = engine

    config = Configurator(settings=settings)

    config.include("pyramid_jinja2")

    config.include("pyramid_debugtoolbar")

    config.add_route("home", "/")

    config.add_route("data", "/data")

    config.add_route("data_advanced", "/data_advanced")

    config.add_route("data_yadcf", "/data_yadcf")

    config.add_route("dt_110x", "/dt_110x")

    config.add_route("dt_110x_custom_column", "/dt_110x_custom_column")

    config.add_route("dt_110x_basic_column_search",
                     "/dt_110x_basic_column_search")

    config.add_route("dt_110x_advanced_column_search",
                     "/dt_110x_advanced_column_search")

    config.add_route("dt_110x_yadcf", "/dt_110x_yadcf")

    config.scan()

    json_renderer = JSON()

    json_renderer.add_adapter(date, date_adapter)

    config.add_renderer("json_with_dates", json_renderer)

    config.add_jinja2_renderer('.html')

    return config.make_wsgi_app()
开发者ID:Pegase745,项目名称:sqlalchemy-datatables,代码行数:47,代码来源:__init__.py

示例8: main

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

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

    # Add .html extension as a renderer
    config.add_jinja2_renderer('.html')

    config.include('jsa.views.home')

    config.scan()

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

示例9: main

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import add_jinja2_renderer [as 别名]
def main(global_config, **settings):
    """ This function returns a Pyramid WSGI application.
    """
    config = Configurator(settings=settings)
    config.include('pyramid_jinja2')
    config.include('pyramid_fanstatic')
    config.add_jinja2_renderer('.html')
    config.add_static_view('static', 'static', cache_max_age=3600)
    config.add_route('home', '/')
    config.add_route('rdm', '/rdm')
    config.add_route('rdmdocs', '/rdm/docs')
    config.add_route('meta', '/rdm/meta')
    config.add_route('odktools', '/rdm/odktools')

    templatesPath = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'templates')
    config.add_jinja2_search_path(templatesPath)

    config.scan()
    return config.make_wsgi_app()
开发者ID:alanorth,项目名称:data.ilri.org-app,代码行数:21,代码来源:__init__.py

示例10: main

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import add_jinja2_renderer [as 别名]
def main(global_config, **settings):
    """ This function returns a Pyramid WSGI application.
    """
    with open(settings['api_key']) as f:
	api_key = f.read().strip()
	zeit.remix.zon_api.API_KEY = api_key
    config = Configurator(settings=settings)
    config.include('pyramid_jinja2')
    config.include('pyramid_redis')
    config.add_jinja2_renderer('.tpl')
    #jinja = config.registry.getUtility(pyramid_jinja2.IJinja2Environment)
    config.add_static_view(name='css', path='zeit.remix:static/css/', cache_max_age=3600)
    config.add_static_view(name='js', path='zeit.remix:static/js/', cache_max_age=3600)
    config.add_static_view(name='img', path='zeit.remix:static/img/', cache_max_age=3600)
    config.add_route('home', '/')
    config.add_route('cache-keywords', '/cache-keywords')
    config.add_route('api', '/{endpoint}')
    config.scan()
    return config.make_wsgi_app()
开发者ID:rdrongow,项目名称:zeit-remix,代码行数:21,代码来源:application.py

示例11: create_app

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import add_jinja2_renderer [as 别名]
def create_app(global_config, **settings):
    """Configure and add static routes and views. Return the WSGI app."""
    settings = get_settings(global_config, **settings)

    config = Configurator(settings=settings)

    config.set_root_factory('h.resources.create_root')

    config.add_subscriber('h.subscribers.add_renderer_globals',
                          'pyramid.events.BeforeRender')

    config.include('h.features')

    config.include('h.views')
    config.include('h.renderers')
    config.include('h.api_client')

    config.include('pyramid_jinja2')
    config.add_jinja2_renderer('.js')
    config.add_jinja2_renderer('.txt')
    config.add_jinja2_renderer('.html')
    config.add_jinja2_renderer('.xml')

    config.add_tween('h.tweens.csrf_tween_factory')

    if config.registry.feature('accounts'):
        config.set_authentication_policy(session_authn)
        config.set_authorization_policy(acl_authz)
        config.include('h.accounts')

    if config.registry.feature('api'):
        api_app = create_api(settings)
        api_view = wsgiapp2(api_app)
        config.add_view(api_view, name='api', decorator=strip_vhm)
        # Add the view again with the 'index' route name, otherwise it will
        # not take precedence over the index when a virtual root is in use.
        config.add_view(api_view, name='api', decorator=strip_vhm,
                        route_name='index')

    if config.registry.feature('claim'):
        config.include('h.claim')

    if config.registry.feature('queue'):
        config.include('h.queue')

    if config.registry.feature('streamer'):
        config.include('h.streamer')

    if config.registry.feature('notification'):
        config.include('h.notification')

    return config.make_wsgi_app()
开发者ID:juli-so,项目名称:h,代码行数:54,代码来源:app.py

示例12: create_app

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import add_jinja2_renderer [as 别名]
def create_app(global_config, **settings):
    """Configure and add static routes and views. Return the WSGI app."""
    settings = get_settings(global_config, **settings)

    config = Configurator(settings=settings)

    config.set_root_factory("h.resources.create_root")

    config.add_subscriber("h.subscribers.add_renderer_globals", "pyramid.events.BeforeRender")

    config.include("h.features")

    config.include("h.db")
    config.include("h.views")
    config.include("h.renderers")
    config.include("h.api_client")

    config.include("pyramid_jinja2")
    config.add_jinja2_renderer(".js")
    config.add_jinja2_renderer(".txt")
    config.add_jinja2_renderer(".html")
    config.add_jinja2_renderer(".xml")

    config.add_tween("h.tweens.csrf_tween_factory")

    if config.registry.feature("accounts"):
        config.set_authentication_policy(session_authn)
        config.set_authorization_policy(acl_authz)
        config.include("h.accounts")

    if config.registry.feature("api"):
        api_app = create_api(settings)
        api_view = wsgiapp2(api_app)
        config.add_view(api_view, name="api", decorator=strip_vhm)
        # Add the view again with the 'index' route name, otherwise it will
        # not take precedence over the index when a virtual root is in use.
        config.add_view(api_view, name="api", decorator=strip_vhm, route_name="index")

    if config.registry.feature("claim"):
        config.include("h.claim")

    if config.registry.feature("queue"):
        config.include("h.queue")

    if config.registry.feature("streamer"):
        config.include("h.streamer")

    if config.registry.feature("notification"):
        config.include("h.notification")

    return config.make_wsgi_app()
开发者ID:brittanystoroz,项目名称:h,代码行数:53,代码来源:app.py

示例13: main

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

    # Configure database connection
    engine = engine_from_config(settings, 'sqlalchemy.')
    sess.configure(bind=engine)
    Base.metadata.bind = engine

    # Configure renderer
    config.include("pyramid_jinja2")
    config.add_jinja2_renderer('.html')

    # Configure routing & wire up views
    config.add_route("feed", "/")
    config.add_route("products", "/api/products")
    config.scan(".views")

    # Manage static files
    config.add_static_view("static", "springboard:static/")

    return config.make_wsgi_app()
开发者ID:thomaswhyyou,项目名称:springboard,代码行数:23,代码来源:app.py

示例14: main

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import add_jinja2_renderer [as 别名]
def main(global_config, **settings):
    """
    Return a new application instance, appropriately configured.
    """
    engine = engine_from_config(settings, 'sqlalchemy.')
    DBSession.configure(bind=engine)
    Base.metadata.bind = engine

    config = Configurator(settings=settings)

    config.include('pyramid_jinja2')
    config.add_jinja2_renderer('.html')
    config.add_jinja2_search_path(
        os.path.join(_current_dir, "templates"))

    config.add_static_view('static', 'static', cache_max_age=3600)
    config.add_route('index', '/')
    config.add_route('signup', '/signup')

    config.scan()
    return config.make_wsgi_app()
开发者ID:KaboomFox,项目名称:embedded-js-in-python-example,代码行数:23,代码来源:__init__.py

示例15: main

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

    settings['SOFTWARE_VERSION'] = __VERSION__

    config = Configurator(settings=settings)

    # Addons
    config.include('pyramid_jinja2')
    # http://docs.pylonsproject.org/projects/pyramid-jinja2/en/latest/#adding-or-overriding-a-renderer
    config.add_jinja2_renderer('.html')
    config.include('cornice')

    # Views and routes
    config.add_static_view('static/app', 'static/app', cache_max_age=0)
    config.add_static_view('static/lib', 'static/lib', cache_max_age=60 * 24)
    config.add_route('index', '/')

    config.scan()

    return config.make_wsgi_app()
开发者ID:hiveeyes,项目名称:kotori,代码行数:23,代码来源:app.py


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