#2175: mako template caching problem
-------------------------------+--------------------------------------------
 Reporter:  tvrtko.sokolovski  |       Owner:  faide     
     Type:  enhancement        |      Status:  new       
 Priority:  normal             |   Milestone:  2.0       
Component:  TurboGears         |     Version:  trunk     
 Severity:  normal             |    Keywords:  mako cache
-------------------------------+--------------------------------------------
 There is a potential problem with mako template caching the way it is used
 by TG2. If you expose a controller method and decorate it with mako
 template it gets served 2 or 3 times slower than when you expose a "raw"
 method which uses mako.lookup.TemplateLookup to rended template directly.

 For example:
 {{{
 class MyController(object)
     @expose('mako:proj.templates.mako_speed')
     def automatic(self):
         return dict()
 }}}
 is 3 times slower than
 {{{
 from mako.template import Template
 from mako.lookup import TemplateLookup

 templates = '...full path...'
 mylookup = TemplateLookup(
     directories=[templates],
     # same difference with and without next line:
     #module_directory=templates,
     output_encoding='utf-8')

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

 class MyController(object)
     @expose()
     def manual(self):
         return serve_template('mako_speed.mak')
 }}}

 There is an example attached to this ticket. Put mako_speed.mak into your
 templates directory, and mako_speed.py into controllers directory. Expose
 MakoSpeedController as "mako_speed" in your root controller.

-- 
Ticket URL: <http://trac.turbogears.org/ticket/2175>
TurboGears <http://www.turbogears.org/>
TurboGears front-to-back web development

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "TurboGears Tickets" group.
This group is read-only. No posting by normal members allowed.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/turbogears-tickets?hl=en?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to