Am 10.03.2010 um 09:08 schrieb Sam:

I'd like to put at the end of each of my Genshi templates the time it
took to render the entire page, starting at the beginning of the
exposed function call.

It seems like it should be easy enough...I inherit all  my pages from
the same master template, so it will be simple to display the time
taken at the bottom of each page.

Now I just need to figure out how to set the time at the beginning of
each function when called.   I assume I'll need to hack up the
TurboGears code itself to make this work.  I'm using TG 1.0.9.

I imagine I can just put in a call to datetime.datetime.now, store
that and then in the template subtract it from the current time.  But
where in the TG code do I put in the original call to
datetime.datetime.now?

Do you want to display this information to your user, or is it just for optimization? If the latter, I'd rather use a cherrypy-filter that can stores start and stop-time, and appends the difference as HTML- comment to the rendered page. Thus you don't make your app aware of this, and can get easily rid ofit in production.

The timestamps should go into the request-object, this is thread-local.

Of course you can also use the filter to just record the start-time as well.

Diez

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