You can also stick it in __init__ so it does not slow down
webware start.

Templates are not threaded, so you may have two sevlets assinging
data to the the same template.  (This can be a dangeous security hole)

Try:
class basicData(SecurePage):
        def __init__(self):
                SecurePage.__init__(self)
                self.compTemplate = Template(tempDef)

        def writeHTML(self):
                t = self.compTemplate
                t.what = 'ever'
                self.writeln(t)

-Aaron

Tim Lavoie wrote:
> One thing which I just stumbled across too is that loading the Cheetah
> templates from within writeHTML() or an action method clobbers the
> caching available from within Cheetah.
> 
> If the servlet has the templates initialized outside of that though,
> then the same templates are kept around, and caching works. Of course
> you might still use the servlet for more important dynamic processing,
> but the Cheetah cache is still nice for those bits where you have
> repeated bits of fluff across different pages. Simple example follows:
> 
>  ======================================================================
> 
> from basic import basic  # Note to self, use better class names next time
> from test import test
> from WebKit.Page import Page
> 
> templates = {'basic':basic(),'test':test()}
> 
> class index(Page):
>     def writeHTML(self):
>         tmpl = templates['basic']
>         self.writeln(tmpl)
> 
>     def actions(self):
>         return['foo']
> 
>     def foo(self):
>         tmpl = templates['test']
>         # insert paramater info here
>         self.writeln(tmpl)
> 
> 
> 
> -------------------------------------------------------
> This sf.net email is sponsored by:ThinkGeek
> Welcome to geek heaven.
> http://thinkgeek.com/sf
> _______________________________________________
> Webware-discuss mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/webware-discuss




-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
Webware-discuss mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/webware-discuss

Reply via email to