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
评论列表
文章目录