hmm, there are only a couple of differences between what you are doing
and what we do.

1) we have a variable provider bit that adds tg vars to the the
template namespace
2) we have our own TemplateLookup function

I guess there are a couple of other little bits like the cache
wrapper, etc, but (famous last words) I'm sure those aren't the issue.

I probably won't have time to look into it for a couple days, but it
would be very interesting to know which of these two is causing the
performance differences you're seeing.

On Tue, Jan 27, 2009 at 7:13 AM, qvx <[email protected]> wrote:
>
> 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.
> >
>



-- 
Mark Ramm-Christensen
email: mark at compoundthinking dot com
blog: www.compoundthinking.com/blog

--~--~---------~--~----~------------~-------~--~----~
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