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

Python render_utils.flatten_app_config函数代码示例

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

本文整理汇总了Python中render_utils.flatten_app_config函数的典型用法代码示例。如果您正苦于以下问题:Python flatten_app_config函数的具体用法?Python flatten_app_config怎么用?Python flatten_app_config使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: _render_tumblr_theme

def _render_tumblr_theme(slug):
    """
    Render out the tumblr theme.
    When handled as an URL, gets target=None.
    When called from fabfile as part of render(),
    gets target from env.settings.

    production: Renders files inline.
    staging/development: Points files to 127.0.0.1

    {{ copy.key_name }} for bits of copy. Key name is the first column's value.
    """

    # Set up context bits.
    context = flatten_app_config()

    # For copytext.
    context['copy'] = {}

    # For og image reference
    context['slug'] = slug

    # Loop over the copy in the sheet named for the slug.
    # Append it like it's a dict.
    for item in copytext.Copy()[slug]:
        context['copy'][item.key] = item.value

    # Open the theme's file.
    with open('tumblrs/%s/theme.html.tpl' % slug, 'r') as readfile:
        template_string = unicode(readfile.read())

    # Render the template.
    return render_template_string(template_string, **context)
开发者ID:PereiraM,项目名称:tumble,代码行数:33,代码来源:app.py


示例2: make_ca_context

def make_ca_context(ca, asset_depth=0):
    """
    Create a base-context for rendering views.
    Includes app_config and JS/CSS includers.

    `asset_depth` indicates how far into the url hierarchy
    the assets are hosted. If 0, then they are at the root.
    If 1 then at /foo/, etc.
    """
    context = flatten_app_config()

    copy = copytext.Copy(app_config.COPY_PATH)

    sheet = copy['community_area_data']

    community_area = ''

    for row in sheet:
    	if row['CA_number'] == ca:
    		community_area = row
    		break


    context['COPY'] = copytext.Copy(app_config.COPY_PATH)
    context['JS'] = JavascriptIncluder(asset_depth=asset_depth)
    context['CSS'] = CSSIncluder(asset_depth=asset_depth)
    context['CA'] = row
    return context
开发者ID:chagan,项目名称:there-goes-the-neighborhood,代码行数:28,代码来源:gentrification.py


示例3: _app_config_js

def _app_config_js():
    """
    Render app configuration to javascript.
    """
    config = flatten_app_config()
    js = 'window.APP_CONFIG = ' + json.dumps(config, cls=BetterJSONEncoder)

    return js, 200, { 'Content-Type': 'application/javascript' }
开发者ID:nprapps,项目名称:elections14,代码行数:8,代码来源:static_app.py


示例4: _app_config_js

def _app_config_js():
    """
    This includes both client-side config and some COPY vars we need in JS.
    """
    config = flatten_app_config()
    js = 'window.APP_CONFIG = ' + json.dumps(config) + ';'

    features = {}
    data = copytext.Copy(app_config.COPY_PATH)
    for feature in data['feature_list']:
        features[feature['key']] = dict(zip(feature._columns, feature._row))

    features = 'window.FEATURES = ' + json.dumps(features) + ';'

    return '\n'.join([js, features]), 200, { 'Content-Type': 'application/javascript' }
开发者ID:miguelpaz,项目名称:playgrounds2,代码行数:15,代码来源:app.py


示例5: make_context

def make_context(asset_depth=0):
    """
    Create a base-context for rendering views.
    Includes app_config and JS/CSS includers.

    `asset_depth` indicates how far into the url hierarchy
    the assets are hosted. If 0, then they are at the root.
    If 1 then at /foo/, etc.
    """
    context = flatten_app_config()

    context['COPY'] = PlayersCopy(app_config.COPY_PATH)
    context['JS'] = JavascriptIncluder(asset_depth=asset_depth)
    context['CSS'] = CSSIncluder(asset_depth=asset_depth)

    return context
开发者ID:INN,项目名称:power-players,代码行数:16,代码来源:helpers.py


示例6: _app_config_js

def _app_config_js():
    config = flatten_app_config()
    js = 'window.APP_CONFIG = ' + json.dumps(config)

    return js, 200, { 'Content-Type': 'application/javascript' }
开发者ID:PereiraM,项目名称:papertrail,代码行数:5,代码来源:app.py


示例7: _app_config_js

def _app_config_js():
    config = flatten_app_config()
    js = "window.APP_CONFIG = " + json.dumps(config)

    return js, 200, {"Content-Type": "application/javascript"}
开发者ID:juaneduardo,项目名称:m_edicion,代码行数:5,代码来源:app.py


示例8: _render_tumblr_theme

def _render_tumblr_theme(slug):
    context = flatten_app_config()
    return render_template('%s-theme.html' % slug, **context)
开发者ID:dannydb,项目名称:tumblr-blog,代码行数:3,代码来源:app.py


示例9: _app_config_js

def _app_config_js(slug):
    config = flatten_app_config()
    config.update(flatten_post_config(slug))
    js = 'window.APP_CONFIG = ' + json.dumps(config)

    return js, 200, { 'Content-Type': 'application/javascript' }
开发者ID:BenHeubl,项目名称:lookatthis,代码行数:6,代码来源:static_post.py


示例10: _app_config_js

def _app_config_js():
    config = flatten_app_config()
    js = 'window.APP_CONFIG = ' + json.dumps(config, cls=BetterJSONEncoder)

    return make_response(js, 200, { 'Content-Type': 'application/javascript' })
开发者ID:BlueMoon3000,项目名称:app-template,代码行数:5,代码来源:static.py


示例11: test_app_config_no_db_credentials

 def test_app_config_no_db_credentials(self):
     from render_utils import flatten_app_config
     config = flatten_app_config()
     self.assertIsNone(config.get('database'))
开发者ID:katlonsdorf,项目名称:elections16,代码行数:4,代码来源:test_app.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python render_utils.load_graphic_config函数代码示例发布时间:2022-05-26
下一篇:
Python render.render函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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