I just tried using mako manually and for 100 requests
time dropped from (TG2) 19.36 sec to (manually) 3.36 sec

from mako.template import Template
from mako.lookup import TemplateLookup

mylookup = TemplateLookup(
    directories=[
        '/templates',
        '/templates/contacts',],
    module_directory='/temp/mako_modules',
    output_encoding='utf-8')

def serve_template(templatename, **kwargs):
    mytemplate = mylookup.get_template(templatename)
    return mytemplate.render(**kwargs)

import tg
class MyController(RestController):
    @expose()
    def edit(self, id):
        contact = get_restricted_instance(Contact, id)
        return serve_template('edit.mak', tg=tg, contact=contact)

On Jan 27, 12:59 pm, Jorge Vargas <[email protected]> wrote:
> On Tue, Jan 27, 2009 at 7:55 AM, qvx <[email protected]> wrote:
>
> > Usually I don't care much about speed, but I have one
> > page that takes longer to render than I like so I used
> > mako to rewrite it (I did this several times in the past on TG1).
> > To my surprise it was slower for the first time. Usually it
> > would be several times faster
>
> > So I wonder if this is just a fluke or if there is maybe a problem
> > with TG2 use of mako.
>
> > Caching of templates or something?
>
> we'll need more info. Your saying it slower on the first load then
> faster? if so this is the cache, that is how it works. Also "faster"
> isn't really a measure, how fast how slow, a sample and/or numbers are
> appreciated.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears" 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/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to