Exemple #1
0
                'DEBUG': debug,
            }
            old_settings = _swap_settings(new_settings)
            try:
                template = django.template.loader.get_template(file_name)

                return template.render(Context(template_dict))
            finally:
                _swap_settings(old_settings)
        
                if not debug:
                    template_cache[abspath] = template
    
    template_module_name = 'google.appengine.ext.webapp.template'
    template = ModuleType(name=template_module_name)
    template.render = render
    template.template_cache = template_cache
    
    # 2.7 has webapp point to webapp2, which has not template module.
    # So adding one shouldn't cause problems for other apps, developed for
    # webapp2.
    from google.appengine.ext import webapp
    sys.modules[template.__name__] = template
    webapp.template = template
    
    # Add this module to sys.modules as the dirname, so that it doesn't
    # imported twice via a different module name.
    console_module_name = os.path.basename(BASEDIR)
    this_module = get_this_module()
    sys.modules[console_module_name] = this_module
    sys.modules['console'] = this_module