It looks like the info in the logs could be down to the whole page
processing, but very simple pages (no db) consistently taking 500ms+
Ill give it a try without the zipimport.
I'm just using the loader cache from the cookbook (removed the
bytecode cache), jinja works great, although I did need to force
caching off in dev or the internal caches do not update after template
changes...
import config
import os
import sys
from google.appengine.api import memcache
sys.path.insert(0, 'lib/jinja2.zip')
from jinja2 import Environment, FunctionLoader , TemplateNotFound
def jinja2_template_loader(templatename):
templatepath = os.path.abspath(os.curdir+'/templates/'+templatename)
template = memcache.get(templatepath+config.VERSION)
if template is None:
try:
template = file(templatepath).read()
if config.LIVE:
memcache.set(templatepath+config.VERSION,template)
except:
template = None
return template
if config.LIVE:
jinja2_environment = Environment(loader = FunctionLoader
(jinja2_template_loader),cache_size=50)
else:
jinja2_environment = Environment(loader = FunctionLoader
(jinja2_template_loader),cache_size=0)
def render(template_name,context):
template = jinja2_environment.get_template(template_name)
context["stats"]="LIVE:" +str(config.LIVE) + " DEBUG:" +str
(config.DEBUG)
return template.render(context)
On Jan 7, 7:39 pm, "Rodrigo Moraes" <[email protected]> wrote:
> On Wed, Jan 7, 2009 at 2:16 PM, Anthony wrote:
> > Is it normal for the zipimporter to take 500-1000ms every request -
> > should it be caching internally?
>
> > I'm importing like so:
>
> > # templates.py
> > sys.path.insert(0, 'lib/jinja2.zip')
> > from jinja2 import Environment, FunctionLoader , TemplateNotFound ,
> > MemcachedBytecodeCache
>
> > Will it still be caching if im not importing the zip dircetly in the
> > main.py?
>
> Not an answer to your question (which I'd like to know :), just a
> warning: you won't be able to use MemcachedBytecodeCache from Jinja2,
> because bytecode usage is not allowed in App Engine.
>
> The example using MemcachedBytecodeCache in the App Engine Cookbook
> only works in the dev server, not in production. :-/
>
> Apart from this, Jinja2 implementation is very smooth. :)
>
> -- rodrigo
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google App Engine" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/google-appengine?hl=en
-~----------~----~----~----~------~----~------~--~---