本文整理汇总了Python中aspen.website.Website.renderer_default方法的典型用法代码示例。如果您正苦于以下问题:Python Website.renderer_default方法的具体用法?Python Website.renderer_default怎么用?Python Website.renderer_default使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类aspen.website.Website
的用法示例。
在下文中一共展示了Website.renderer_default方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: open
# 需要导入模块: from aspen.website import Website [as 别名]
# 或者: from aspen.website.Website import renderer_default [as 别名]
# ======================================
return {
'img': img,
'screenshot': screenshot,
'translate': translate,
'version': opts['version'],
'homepage': False,
'show_ga': opts['show_ga'],
}
opts['show_ga'] = parse.yes_no(os.environ.get( 'ASPEN_IO_SHOW_GA'
, 'no'
).decode('US-ASCII'))
opts['base'] = ''
# this is a dirty nasty hack. We should store the version in the aspen module somewhere
opts['version'] = open(os.path.join(website.www_root,'..','version.txt')).read()[:-len('-dev')]
# no idea why this doesn't work
website.renderer_default = 'tornado'
open('/tmp/debugout','a').write('doccnf:' + website.renderer_default + '\n')
website.algorithm.insert_after('dispatch_request_to_filesystem', add_stuff_to_request_context)
if __name__ == '__main__':
from aspen import serve
serve(website)
示例2: Website
# 需要导入模块: from aspen.website import Website [as 别名]
# 或者: from aspen.website.Website import renderer_default [as 别名]
from gratipay.security import authentication, csrf, security_headers
from gratipay.utils import erase_cookie, http_caching, i18n, set_cookie, timer
from gratipay.version import get_version
from gratipay.renderers import csv_dump, jinja2_htmlescaped, eval_, scss
import aspen
from aspen.website import Website
website = Website()
# Configure renderers
# ===================
website.renderer_default = 'unspecified' # require explicit renderer, to avoid escaping bugs
website.renderer_factories['csv_dump'] = csv_dump.Factory(website)
website.renderer_factories['eval'] = eval_.Factory(website)
website.renderer_factories['jinja2_htmlescaped'] = jinja2_htmlescaped.Factory(website)
website.renderer_factories['scss'] = scss.Factory(website)
website.default_renderers_by_media_type['text/html'] = 'jinja2_htmlescaped'
website.default_renderers_by_media_type['text/plain'] = 'jinja2' # unescaped is fine here
website.default_renderers_by_media_type['text/css'] = 'scss'
website.default_renderers_by_media_type['image/*'] = 'eval'
website.renderer_factories['jinja2'].Renderer.global_context = {
# This is shared via class inheritance with jinja2_htmlescaped.
'b64encode': base64.b64encode,
'enumerate': enumerate,
'filter': filter,
示例3: Website
# 需要导入模块: from aspen.website import Website [as 别名]
# 或者: from aspen.website.Website import renderer_default [as 别名]
website = Website(www_root='www', project_root='.')
# Manually register markdown renderer to work around Heroku deployment woes.
website.renderer_factories['markdown'] = gfm.Factory(website)
website.renderer_factories['jinja2'].Renderer.global_context = {
'range': range,
'unicode': unicode,
'enumerate': enumerate,
'len': len,
'float': float,
'type': type,
'str': str,
}
website.renderer_default = "markdown"
def add_nav_to_website(website):
website.nav = NavItem(website, None, website.www_root, '')
def add_nav_current_to_context(dispatch_result, website):
path = dispatch_result.match
if basename(path) in website.indices:
path = dirname(path)
return {'nav_current': website.nav.by_fs.get(path, website.nav)}
def add_nav_next_to_context(nav_current, website):
return {'nav_next': nav_current.next_child}
def only_allow_certain_methods(request):