template.py 文件源码

python
阅读 27 收藏 0 点赞 0 评论 0

项目:Deploy_XXNET_Server 作者: jzp820927 项目源码 文件源码
def _load_internal_django(path, debug):
  """Load the given template using the django found in apphosting._internal."""
  import google.appengine._internal.django.conf
  import google.appengine._internal.django.template.loader
  from google.appengine._internal import django

  abspath = os.path.abspath(path)

  if not debug:
    template = template_cache.get(abspath, None)
  else:
    template = None

  if not template:
    directory, file_name = os.path.split(abspath)
    settings = dict(
        TEMPLATE_LOADERS=(
            'google.appengine._internal.'
            'django.template.loaders.filesystem.load_template_source',
        ),
        TEMPLATE_DIRS=(directory,),
        TEMPLATE_DEBUG=debug,
        DEBUG=debug)

    django.conf.settings.configure(**settings)
    template = django.template.loader.get_template(file_name)

    if not debug:
      template_cache[abspath] = template

    def wrap_render(context, orig_render=template.render):


      django.conf.settings.configure(**settings)
      return orig_render(context)
    template.render = wrap_render

  return template
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号