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


Python Configurator.add_jinja2_search_path方法代码示例

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


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

示例1: main

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import add_jinja2_search_path [as 别名]
def main(global_config, **settings):
    """ This function returns a WSGI application.
    """
    engine = engine_from_config(settings, 'sqlalchemy.')
    get_root = appmaker(engine)
    config = Configurator(settings=settings, root_factory=get_root)
    # allow jinja2 templates! requires pyramid_jinja2 package.
    config.include('pyramid_jinja2')
    jinja2_extensions=[
        # Allow arbitrary expressions:
        'jinja2.ext.do',
        # Add a trans block tag:
        'jinja2.ext.i18n',
        # Adds break, continue to for loops:
        'jinja2.ext.loopcontrols',
        # Add a with statement for explicit variable scopes:
        'jinja2.ext.with_',
        # Allow autoescaping to be disabled:
        'jinja2.ext.autoescape',
    ]
    for ext in jinja2_extensions:
        config.add_jinja2_extension(ext)
    config.add_jinja2_search_path("counterpoint:templates")
    # add static files folder
    config.add_static_view('static', 'counterpoint:static', cache_max_age=3600)
    # add views
    config.add_view('counterpoint.views.view_exercise',
                    context='counterpoint.models.MyRoot',
                    renderer="exercise.jinja2")
    return config.make_wsgi_app()
开发者ID:anthonyt,项目名称:counterpoint-online,代码行数:32,代码来源:__init__.py

示例2: main

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import add_jinja2_search_path [as 别名]
def main(global_config, **settings):
    """ This function returns a Pyramid WSGI application.
    """
    authn_policy = AuthTktAuthenticationPolicy('seekrit')
    authz_policy = ACLAuthorizationPolicy()
    my_session_factory = UnencryptedCookieSessionFactoryConfig('itsaseekreet')
    config = Configurator(
        settings=settings,
        root_factory='scribeui_pyramid.modules.app.resources.RootFactory',
        authentication_policy=authn_policy,
        authorization_policy=authz_policy,
        session_factory=my_session_factory
    )
    config.include('pyramid_jinja2')
    config.include('.modules')
    config.add_jinja2_search_path("scribeui_pyramid:templates")
    environment = config.get_jinja2_environment()
    environment.globals['time'] = get_rid()
    environment.globals['getattr'] = jinja_getattr
    config.add_static_view(
        'static',
        'scribeui_pyramid:static',
        cache_max_age=3600
    )
    return config.make_wsgi_app()
开发者ID:smercier,项目名称:scribeui,代码行数:27,代码来源:__init__.py

示例3: main

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import add_jinja2_search_path [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(
        uuid4().__str__(), callback=groupfinder, hashalg='sha512')
    authz_policy = ACLAuthorizationPolicy()
    config = Configurator(settings=settings, root_factory='plog.models.RootFactory', session_factory=sf)
    config.set_authentication_policy(authn_policy)
    config.set_authorization_policy(authz_policy)
    config.include('pyramid_jinja2')
    config.add_jinja2_search_path("plog:templates")
    config.add_static_view('static', 'static', cache_max_age=3600)
    config.add_route('home', '/')
    config.add_route('login', '/login')
    config.add_route('logout', '/logout')
    config.add_route('admin', '/admin')
    config.add_route('add_post', '/post/add')
    config.add_route('add_user', '/user/add')
    config.add_route('add_group', '/group/add')
    config.add_route('del_group', '/group/del/{group_name}')
    config.add_route('del_user', '/user/del/{username}')
    config.add_route('profile', '/user/profile/{username}')
    config.add_route('edit_user', '/user/edit/{username}')
    config.add_route('edit_post', '/post/edit/{slug}')
    config.add_route('delete_post', '/post/del/{slug}')
    config.add_route('post', '/post/{slug}')
    config.scan()
    return config.make_wsgi_app()
开发者ID:MillerTom,项目名称:Plog,代码行数:33,代码来源:__init__.py

示例4: main

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import add_jinja2_search_path [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='geotimeline: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_extension('html')
    config.add_renderer('.html', 'pyramid_jinja2.renderer_factory')
    config.add_renderer('json', json_renderer)
    config.add_jinja2_search_path('geotimeline:templates')
    config.add_static_view('static', 'static', cache_max_age=3600)
    config.add_route('home', '/')
    config.add_route('login', '/login')
    config.add_route('logout', '/logout')
    config.add_route('map', '/timemap')
    config.add_route('events', '/getCollections')
    config.add_route('saveEvent', '/saveEvent')
    config.add_route('saveCollection', '/saveCollection')
    config.add_route('deleteEvent', '/deleteEvent/{id}')
    config.add_route('settings', '/settings')
    #config.add_route('friends-events', '/getFriendsEvents')
    config.scan()
    return config.make_wsgi_app()
开发者ID:sdc50,项目名称:geotimeline,代码行数:34,代码来源:__init__.py

示例5: main

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

    initialize_sql(settings)

    config = Configurator(settings=settings)

    config.include('pyramid_tm')
    config.include('pyramid_redis_sessions')
    config.include('pyramid_jinja2')

    config.add_jinja2_search_path('potte:templates/')

    # auth
    authn_policy = AuthTktAuthenticationPolicy(
        settings['authtkt.secret'],
        callback=auth_groupfinder,
        hashalg='sha512',
    )
    authz_policy = ACLAuthorizationPolicy()
    config.set_authentication_policy(authn_policy)
    config.set_authorization_policy(authz_policy)

    # request
    config.set_request_factory(RequestWithUserAttribute)

    config.include('.urls')

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

示例6: main

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import add_jinja2_search_path [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

示例7: main

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import add_jinja2_search_path [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)

    # pyramid_jinja2 configuration
    config.include('pyramid_jinja2')
    config.add_jinja2_search_path("pyramid_example:templates")

    # SACRUD
    config.include('sacrud.pyramid_ext', route_prefix='/admin')
    settings = config.registry.settings
    settings['sacrud.models'] = {'Test': [MyModel], }

    # include view
    includeme(config)

    # include from other model
    config.include('pyramid_example.my_super_includeme')

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

示例8: main

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import add_jinja2_search_path [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.include('pyramid_jinja2')
    config.add_jinja2_search_path("myproject:templates")
    config.add_static_view('static', 'static', cache_max_age=3600)
    config.add_route('home', '/')
    config.add_route('menu', '/menu')
    config.add_route('placeOrder', '/placeOrder')
    config.add_route('orders', '/orders')
    config.add_route('pos','/pos')
    config.add_route('admin', '/admin')
    config.add_route('about', '/about')
    config.add_route('test', '/test')
    config.add_route('addMenuItem', '/addMenuItem')
    config.add_route('editMenuItem', '/editMenuItem')
    config.add_route('payForItems', '/payForItems')
    config.scan()
    return config.make_wsgi_app()
开发者ID:umdrawa2,项目名称:4350Proj,代码行数:27,代码来源:__init__.py

示例9: main

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import add_jinja2_search_path [as 别名]
def main(global_config, **settings):
    """ This function returns a Pyramid WSGI application.
    """
    config = Configurator(settings=settings)
    config.add_static_view(name='static', path='static', cache_max_age=3600)
    config.add_static_view(name='/favicon.ico', path='static', cache_max_age=3600)

    # Jinja templates here
    config.include('pyramid_jinja2')
    config.add_jinja2_search_path("www:templates")

    # Sessions here
    config.include("pyramid_beaker")
    session_factory = BeakerSessionFactoryConfig(
        type='file',
        key='session_id',
        secret='Please Keep 1t Encrypted',
        data_dir='/tmp/hh/sessions/data',
        data_lock_dir='/tmp/hh/sessions/lock',
        timeout=3600,  # 1 hour sessions
    )
    config.set_session_factory(session_factory)

    # Routes here
    config.add_route('dashboard', '/dashboard')
    config.add_route('welcome', '/')
    config.add_route('login', '/login')
    config.add_route('logout', '/logout')
    config.add_route('hosts', '/hosts')

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

示例10: main

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import add_jinja2_search_path [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)
    authz_policy = ACLAuthorizationPolicy()

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

    config.include('pyramid_jinja2')
    config.add_jinja2_search_path("pyramid_easy_blog:templates")
    config.add_static_view('static', 'static', cache_max_age=3600)

    #config.include('pyramid_easy_blog.connector')

    config.add_route('login', '/login')
    config.add_route('logout', '/logout')
    config.add_route('view_blog', '/')
    config.add_route('add_post', '/add_post/')
    config.add_route('connector', '/connector')
    config.add_route('images_json', '/images_json')
    config.add_route('view_post', '/{postid}')
    config.add_route('edit_post', '/{postid}/edit_post')
    config.scan()
    return config.make_wsgi_app()
开发者ID:uralbash,项目名称:pyramid_easy_blog,代码行数:32,代码来源:__init__.py

示例11: main

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

    # templates
    config.add_notfound_view(notfound, append_slash=False)
    config.add_renderer('.html', 'pyramid_jinja2.renderer_factory')
    config.add_renderer('.jinja2', 'pyramid_jinja2.renderer_factory')
    config.add_jinja2_search_path('templates')

    # apps
    config.include('main')
    config.include('businesses', route_prefix='/api/v1')
    config.include('reviews', route_prefix='/api/v1')
    config.include('auth', route_prefix='/api/v1')

    # static files
    config.add_route('catchall_static', '/*subpath')
    config.add_static_view('static', 'static', cache_max_age=3600)
    config.add_view('service.static.static_view', route_name='catchall_static')

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

示例12: main

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import add_jinja2_search_path [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
    authentication_policy = AuthTktAuthenticationPolicy('somesecret')
    authorization_policy = ACLAuthorizationPolicy()
    session_factory = session_factory_from_settings(settings)
    config = Configurator(settings=settings,
                          authentication_policy=authentication_policy,
                          authorization_policy=authorization_policy,
                          root_factory=Root,
                          )
    config.set_session_factory(session_factory)
    # jinja 2 config
    config.add_jinja2_search_path("chessnut:templates")
    config.include('pyramid_jinja2')

    # views
    config.add_static_view('static', 'static', cache_max_age=3600)
    config.add_route('home', '/')
    config.add_route('login', '/login')
    config.add_route('logout', '/logout')
    config.add_route('twauth', '/twauth')
    config.add_route('index', '/index')
    config.add_route('register', '/register')
    config.add_route('mentions', '/mentions')
    config.scan()
    return config.make_wsgi_app()
开发者ID:tsnaomi,项目名称:Chessnut,代码行数:32,代码来源:__init__.py

示例13: main

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

    config.add_static_view('static', 'contacts:static', cache_max_age=3600)
    config.add_route('home', '/')
    config.add_route('view-contact', '/view-contact/{id}')
    config.include('pyramid_jinja2')
    config.add_jinja2_search_path("contacts:templates")                    
                    
    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
        event.request.fs = GridFS(db)
    db_uri = settings['mongodb.url']
    conn = pymongo.Connection(db_uri)
    config.registry.settings['mongodb_conn'] = conn
    config.add_subscriber(add_mongo_db, NewRequest)
                        
    return config.make_wsgi_app()
开发者ID:aaguirre,项目名称:FrameWars.Contacs,代码行数:27,代码来源:__init__.py

示例14: main

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import add_jinja2_search_path [as 别名]
def main(global_config, **settings):
    """ This function returns a Pyramid WSGI application.
    """
    my_session_factory = UnencryptedCookieSessionFactoryConfig('itsaseekreet', timeout=86400)
    engine = engine_from_config(settings, 'sqlalchemy.')
    DBSession.configure(bind=engine)
    Base.metadata.bind = engine
    authn_policy = AuthTktAuthenticationPolicy('seekrit', hashalg='sha512')
    authz_policy = ACLAuthorizationPolicy()
    config = Configurator(settings=settings, session_factory=my_session_factory, root_factory=AuthRoot)
    config.set_authentication_policy(authn_policy)
    config.set_authorization_policy(authz_policy)
    config.include('pyramid_jinja2')
    config.include("cornice")
    config.include('velruse.providers.github')
    config.add_renderer('.html', factory='pyramid_jinja2.renderer_factory')
    config.add_jinja2_search_path("verse:templates")
    config.add_static_view('static', 'static', cache_max_age=3600)
    config.set_default_permission('view')
    config.add_github_login_from_settings(prefix='velruse.github.')

    setup_urls(config)
    config.scan('verse.views')
    config.scan('verse.setup_views')
    config.scan('verse.account_views')
    return config.make_wsgi_app()
开发者ID:binarydud,项目名称:verse,代码行数:28,代码来源:__init__.py

示例15: main

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import add_jinja2_search_path [as 别名]
def main(global_config, **settings):
    """ This function returns a Pyramid WSGI application.
    """
    engine = engine_from_config(settings, 'sqlalchemy.', poolclass=NullPool)
    DBSession.configure(bind=engine)
    my_session_factory = UnencryptedCookieSessionFactoryConfig('itsaseekreet')
    Base.metadata.bind = engine
    config = Configurator(
        settings=settings,
        session_factory=my_session_factory,
        authentication_policy=SessionAuthenticationPolicy())
    Base.metadata.create_all(engine)
    config.include('pyramid_chameleon')
    config.include('pyramid_jinja2')
    config.add_jinja2_search_path("jkh:templates")
    config.add_static_view('static', 'static', cache_max_age=3600)
    config.add_route('home', '/')
    config.add_route('user', '/user')
    config.add_route('news', '/news')
    config.add_route('about', '/about')
    config.add_route('registration', '/registration')
    config.add_route('login', '/login')
    config.add_route('logout', '/logout')
    config.add_route('passremind', '/passremind')
    config.add_route('settings', '/settings')
    config.add_notfound_view(not_found, append_slash=True)

    config.include('sacrud.pyramid_ext', route_prefix='/admin')
    settings = config.registry.settings
    settings['sacrud.models'] = {"": [User, Country, Tarif, Service, Region]}

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


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