[Twisted-web] about macro and render

Manlio Perillo manlio_perillo at libero.it
Wed Feb 21 06:03:30 CST 2007


Valentino Volonghi aka Dialtone ha scritto:
> 
> 
> On Wed, 21 Feb 2007 12:32:08 +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 loading.
> 
> 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.



Regards  Manlio Perillo



More information about the Twisted-web mailing list