I am using Python 2.5 in App Engine and trying to get JLJJ2 to work with it.
To initialize the environment, I use:
@staticmethod
'compiled' is the directory in my GAE project. But I keep getting TemplateNotFound exceptions ??
I compiled the templates using:
env = Environment(extensions=['jinja2.ext.i18n']) env.filters['euros'] = Euros db_runtimes = Runtimes.all()
The resulting code looks great. Any ideas? I hope you can help me. This article by Rodrigo Moraes shows that loading templates from python modules is very fast. But in this proof of the 2009 concept, he “cracked” the Jinja code to be able to run the code. I think ModuleLoader should do the same job. https://groups.google.com/group/pocoo-libs/browse_thread/thread/748b0d2024f88f64
testmod.py looks like this:
from __future__ import division from jinja2.runtime import LoopContext, TemplateReference, Macro, Markup, TemplateRuntimeError, missing, concat, escape, markup_join, unicode_join, to_string, identity, TemplateNotFound name = u'testmod.py' def root(context, environment=environment): if 0: yield None yield u'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"\n"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\n<html xmlns="http://www.w3.org/1999/xhtml">\n<head>\n<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />\n<title>TEST</title>\n</head>\n<body>\n\t<p>test template</p>\n</body>\n</html>' blocks = {} debug_info = ''
And the page handler:
def get(self): my_env = myEnv.get() page = 'testmod.py' template = my_env.get_template(page) self.response.out.write(template.render({}))
I also tried to get the template without the .py extension.
source share