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


Python MicrositeConfiguration.get_microsite_template_path方法代码示例

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


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

示例1: render_to_string

# 需要导入模块: from microsite_configuration.middleware import MicrositeConfiguration [as 别名]
# 或者: from microsite_configuration.middleware.MicrositeConfiguration import get_microsite_template_path [as 别名]
def render_to_string(template_name, dictionary, context=None, namespace='main'):

    # see if there is an override template defined in the microsite
    template_name = MicrositeConfiguration.get_microsite_template_path(template_name)

    context_instance = Context(dictionary)
    # add dictionary to context_instance
    context_instance.update(dictionary or {})
    # collapse context_instance to a single dictionary for mako
    context_dictionary = {}
    context_instance['settings'] = settings
    context_instance['EDX_ROOT_URL'] = settings.EDX_ROOT_URL
    context_instance['marketing_link'] = marketing_link

    # In various testing contexts, there might not be a current request context.
    if edxmako.middleware.requestcontext is not None:
        for d in edxmako.middleware.requestcontext:
            context_dictionary.update(d)
    for d in context_instance:
        context_dictionary.update(d)
    if context:
        context_dictionary.update(context)
    # fetch and render template
    template = edxmako.lookup[namespace].get_template(template_name)
    return template.render_unicode(**context_dictionary)
开发者ID:ServboltSystems,项目名称:edx-platform,代码行数:27,代码来源:shortcuts.py

示例2: render_to_response

# 需要导入模块: from microsite_configuration.middleware import MicrositeConfiguration [as 别名]
# 或者: from microsite_configuration.middleware.MicrositeConfiguration import get_microsite_template_path [as 别名]
def render_to_response(template_name, dictionary=None, context_instance=None, namespace='main', **kwargs):
    """
    Returns a HttpResponse whose content is filled with the result of calling
    lookup.get_template(args[0]).render with the passed arguments.
    """

    # see if there is an override template defined in the microsite
    template_name = MicrositeConfiguration.get_microsite_template_path(template_name)

    dictionary = dictionary or {}
    return HttpResponse(render_to_string(template_name, dictionary, context_instance, namespace), **kwargs)
开发者ID:ServboltSystems,项目名称:edx-platform,代码行数:13,代码来源:shortcuts.py


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