I think you'd better define web.ctx.render for each language in the very begininning, not in every request.
By the way, you can set up only one render, and call render["en"] for specific locale. On Jun 15, 6:15 pm, Emiliano Martinez Contreras <[email protected]> wrote: > Hi Anand, > > Thanks for the quick reply. In my main sitemanager app what I do is use a > cookie to find out the language of the visitor, according to that cookie a > locale template path is chosen, so what I have is a hook which I then add as > a preprocessor: > > +++ > > def render_hook(): > cookies = web.cookies(lang="en") > lang = cookies.lang > > if lang in settings.VALID_LANGS: > locales_path = os.path.join(settings.TEMPLATES_PATH, "%s/"%(lang)) > > else: > locales_path = os.path.join(settings.TEMPLATES_PATH,"en/") > > web.ctx.render = web.template.render(locales_path, globals={'session': > web.ctx.session}) > > ++++ > > As I said the function is loaded by a preprocessor: > > +++ > > app.add_processor(web.loadhook(render_hook)) > > +++ > > I then return the webs like this: > > +++ > > return web.ctx.render.base(content=web.ctx.render.search(...)) > > +++ > > Perhaps there is something wrong in doing this and the preprocessor forces a > recompilation on each request? > > 2010/6/15 Anand Chitipothu <[email protected]> > > > 2010/6/15 Emiliano Martinez Contreras <[email protected]>: > > > Hi guys, > > > > We've been having serious problems with the performance of a high traffic > > > site. Finally we discovered that most of the time is spent in template > > > compilation. I am using templetor and I like it a lot, I would not like > > to > > > change, moreover, given the amount of templates I have it would be a > > killer > > > to change. > > > > I installed python profiler and profiled the site, url visits that > > require > > > template compilation take more or less 0,4s of cpu, on the other hand > > json > > > serving for example takes only 0,01s, which is more or less coherent. I > > > would like to reduce that 0,4s and I read that compiling templetor > > templates > > > and using GAE render (I am not using GAE btw) may reduce that time by an > > > order of magnitude. > > > > So I've followed these instructions: > > > >http://webpy.org/cookbook/templates_on_gae > > > > The thing is that template.py compile does not produce a correct result, > > it > > > muddles up the indentation of for loops and if/else conditions inside the > > > templates, making it impossible to import the outcome due to indentation > > > erros. > > > > Any clue? > > > Compiling templates should not be performance problem because it is > > done only once at the beginning. If it is recompiling the templates > > every time, then there is something wrong with your settings. > > > What is the version of web.py that you are using? Can you provide a > > sample template that is failing? > > > -- > > You received this message because you are subscribed to the Google Groups > > "web.py" group. > > To post to this group, send email to [email protected]. > > To unsubscribe from this group, send email to > > [email protected] <webpy%[email protected]>. > > For more options, visit this group at > >http://groups.google.com/group/webpy?hl=en. > > -- You received this message because you are subscribed to the Google Groups "web.py" 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/webpy?hl=en.
