[Twisted-web] html cache with timeout

Valentino Volonghi aka Dialtone dialtone at divmod.com
Wed Feb 2 17:13:10 MST 2005

On Wed, 2 Feb 2005 20:03:47 +0100, Andrea Arcangeli <andrea at cpushare.com> wrote:
> I'd certainly need to cache the xml fragments.
> I've code like this:
> class xx_class(rend.Fragment):
> 	docFactory = loaders.xmlfile('xxx.xml', XMLDIR, ignoreDocType = True)
> I'd need to cache the output of the above.
> It's not exactly clear to me how to do that with the stan cache, could
> you make an example (or if you already did it in weever let me know and
> I'll have a look).


Here it is.
Search for the render_content method inside the MasterPage class.

It is like this:

    def render_content(self, ctx, data):
        ct = t.cached(name=str(self.__class__), lifetime=10)[self.content(self.args, data[FIRST_POST])]
        ctx.tag.fillSlots('content', ct)
        return ctx.tag

I already know that using self.__class__ as a name is not enough, but that was just a test and I already removed it until it is merged in nevow trunk.

More information about the Twisted-web mailing list