[Twisted-web] Cannot render a LivePage more than once

Juanjo Conti jjconti at gmail.com
Thu Jul 9 14:16:08 EDT 2009


I've actually realised that the problem is happening when I use this IndexPage:

class IndexPage(rend.Page):

    def __init__ ( self, *args, **kwargs ):
        rend.Page.__init__ ( self, *args, **kwargs )
        self.ter = TerPage()
        self.graph = GraphPage()


    docFactory = loaders.stan (
        T.html [ T.head ( title = 'Indice' ),
                 T.body [ T.h1 [ "Pagina principal" ],
                          T.p [ "Ir a ",
                                T.a ( href = 'ter' ) [ "TER" ],
                                " or ",
                                T.a ( href = 'grapf' ) [ "graph" ],
                                ],
                          ]
                 ]
        )


    def child_ter(self, ctx):
        return self.ter

    def child_graph(self, ctx):
        return self.graph

from nevow import appserver
site = appserver.NevowSite(IndexPage())
reactor.listenTCP(8009, site)

I can reaload the IndexPage, but can't the Terpage or GraphPage.

Thanks,

2009/7/9 Juanjo Conti <jjconti at gmail.com>:
> HI! I'm using LivePage from Nevow.Athena like this:
>
> class TerPage(LivePage):
>    docFactory = loaders.stan(T.html[
>        T.head(render=T.directive('liveglue')),
>        T.body(render=T.directive('myElement'))])
>
>    def beforeRender(self, ctx):
>        d = self.notifyOnDisconnect()
>        d.addErrback(self.disconn)
>
>    def disconn(self, reason):
>        del lectores[hash(self.element)]
>
>    def render_myElement(self, ctx, data):
>        self.element = TempElement()
>        self.element.setFragmentParent(self)
>        return ctx.tag[self.element]
>
>    def child_(self, ctx):
>        return TerPage()
>
>
> site = appserver.NevowSite(TerPage())
> reactor.listenTCP(8009, site)
>
> When I load the page for first time, it's rendered ok. But if I hit
> the reload button or someone access it from other computer, this
> exception is shown:
>
> Cannot render a LivePage more than once.
>
> Could you point me the correct way of doing it?
>
> Thanks,
>
> --
> Juanjo Conti
>



-- 
Juanjo Conti



More information about the Twisted-web mailing list