[Twisted-web] Instance of child element class never goes away?

Tommi Virtanen tv at twistedmatrix.com
Wed Nov 9 01:16:48 MST 2005

Jay wrote:
> There's the TopLevel which has one child page -- child_antitrypsin.
> child_antitrypsin is an instance of a Query class that returns a plain old
> HTML string via http.Response.
> The problem I'm having is that the first child_antitrypsin that gets
> instantiated seems to be the only one that ever gets created.  Refreshing
> the page -- or clicking on the link -- gives me the string twice...or three
> times or however many.  So, if the first result was "APPLE", the second
> time, I'd get "APPLEAPPLE" and so on.

I'm guessing you have

class TopLevel(...):
    child_antitrypsin = Query()

which instantiates the child exactly once, at program startup.
You probably wanted

class TopLevel(...):
    def child_antitrypsin(self, ctx): return Query()

But as you provided no details, this is just a guess.
And my crystal ball is all dusty.

More information about the Twisted-web mailing list