[Twisted-web] about macro and render

Valentino Volonghi aka Dialtone dialtone at divmod.com
Wed Feb 21 08:28:54 CST 2007

On Wed, 21 Feb 2007 13:03:30 +0100, Manlio Perillo <manlio_perillo at libero.it> wrote:
>>>class Resource(rend.rend):
>>>   template = ... # The child template to load
>>>   def render_main(self, ctx, data):
>>>      return self.state.setdefault(
>>>               template, loaders.xmlfile(self.template)
>>>               )
>>>Here I'm storing the loader instance in a dictionary, to optimize template 
>>Useless, loaders already have a cache.
>I have read the loaders.py, and, as far as I can see, the cache is *inside* 
>the loader instance.
>This means that the cache is destroyed when the loader istance goes out of 
>the scope; the document is reloaded every time render_main is called.

I see you are actually saving the loader in self.state and this wouldn't let
the loader die. Anyway you just need to provide another class variable for the loader, seems easy.

More information about the Twisted-web mailing list