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


Python AppConfig.jinja_extensions方法代码示例

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


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

示例1: AppConfig

# 需要导入模块: from tg.configuration import AppConfig [as 别名]
# 或者: from tg.configuration.AppConfig import jinja_extensions [as 别名]
# unused here, but needed by TurboGears2
from skylines.lib import app_globals, helpers


base_config = AppConfig()
base_config.renderers = []

base_config.package = skylines

#Enable json in expose
base_config.renderers.append('json')
#Set the default renderer
base_config.default_renderer = 'jinja'
base_config.renderers.append('jinja')
base_config.jinja_extensions = ['jinja2.ext.i18n', 'jinja2.ext.with_', 'jinja2.ext.do']


def install_gettext_callables(app):
    from tg.i18n import ugettext, ungettext
    jinja2_env = app_globals.config['pylons.app_globals'].jinja2_env
    jinja2_env.install_gettext_callables(ugettext, ungettext)
    jinja2_env.autoescape = False
    return app

base_config.register_hook('after_config', install_gettext_callables)

#base_config.renderers.append('mako')
# if you want raw speed and have installed chameleon.genshi
# you should try to use this renderer instead.
# warning: for the moment chameleon does not handle i18n translations
开发者ID:dkm,项目名称:skylines,代码行数:32,代码来源:app_cfg.py

示例2: AppConfig

# 需要导入模块: from tg.configuration import AppConfig [as 别名]
# 或者: from tg.configuration.AppConfig import jinja_extensions [as 别名]
 
"""

from tg.configuration import AppConfig

import tghello
from tghello import model
from tghello.lib import app_globals, helpers 

base_config = AppConfig()
base_config.renderers = []
base_config.prefer_toscawidgets2 = True

base_config.package = tghello

#Enable json in expose
base_config.renderers.append('json')

#Enable genshi in expose to have a lingua franca for extensions and pluggable apps
#you can remove this if you don't plan to use it.
base_config.renderers.append('genshi')

#Set the default renderer
base_config.default_renderer = 'jinja'
base_config.renderers.append('jinja')
base_config.jinja_extensions = ['jinja2.ext.with_']
#Configure the base Ming Setup
base_config.use_ming = True
base_config.use_sqlalchemy=False
base_config.use_transaction_manager=False
开发者ID:42cc,项目名称:tg-hello,代码行数:32,代码来源:app_cfg.py

示例3:

# 需要导入模块: from tg.configuration import AppConfig [as 别名]
# 或者: from tg.configuration.AppConfig import jinja_extensions [as 别名]
base_config.prefer_toscawidgets2 = True

base_config.package = jeyzth42

# Enable json in expose
base_config.renderers.append("json")
# Enable genshi in expose to have a lingua franca
# for extensions and pluggable apps.
# You can remove this if you don't plan to use it.
base_config.renderers.append("genshi")

# Set the default renderer
base_config.default_renderer = "jinja"
base_config.renderers.append("jinja")
base_config.jinja_extensions = ["jinja2.ext.with_"]
# Configure the base Ming Setup
base_config.use_sqlalchemy = False
base_config.use_transaction_manager = False

base_config.use_ming = True
base_config.model = jeyzth42.model
base_config.DBSession = jeyzth42.model.DBSession
# Configure the authentication backend
base_config.auth_backend = "ming"
# YOU MUST CHANGE THIS VALUE IN PRODUCTION TO SECURE YOUR APP
base_config.sa_auth.cookie_secret = "ee7240e9-ec48-4f41-b684-74ca205dea28"
# what is the class you want to use to search for users in the database
base_config.sa_auth.user_class = model.User

from tg.configuration.auth import TGAuthMetadata
开发者ID:jeyzth,项目名称:jeyzth42,代码行数:32,代码来源:app_cfg.py


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