I wouldn't expect it to work any other way than it does. Conceptually,
callMethodOfServlet(servlet, method, *args) actually gets an instance of the
requested servlet (creating a new instance if necessary), calls awake() on
it, calls theServlet.method(*args) and remembers the return value, calls
sleep() on it, recycles the servlet instance, then returns the value.
So callMethodOfServlet() is useful if you want to "ask" another servlet
something and get back a return value. For example, if you're writing a
"table of contents" servlet, it might be useful for it to be able to ask
another servlet for its title by calling its title() method. A line like:
title = self.callMethodOfServlet(servlet, title)
is useful for that. But callMethodOfServlet isn't designed to actually do
anything whose effects are persistent, since the servlet instance is thrown
Perhaps in your case, you'd be better off simply putting the method into a
base class and calling it normally?
> -----Original Message-----
> From: Matt Feifarek [mailto:mattf@...]
> Sent: Monday, August 05, 2002 4:27 PM
> To: Webware; Webware-devel@...
> Cc: Martin Doudoroff
> Subject: [Webware-devel] Page.callMethodOfServlet() and self
> I'm trying to use Page.callMethodOfServlet(), and I've
> noticed that inside
> of the called method, "self" actually corresponds to the
> "secondary" servlet
> (the one who's method is being hijacked) rather than the actual called
> Is this by design, or is it a bug? I understand that it's a
> bit iffy, but it
> kinda breaks a lot of things.
> For example, let's say a method checks on some things, and
> sets a dirty flag
> if those things pass some test:
> class proxy(Page):
> def someMethod(self):
> if some_things_are_true:
> self._dirty = 1
> self._dirty = None
> class main(Page):
> def writeContent(self):
> if self._dirty:
> If one runs the servlet that contains this method (proxy), it
> will work as
> However, if one runs ANOTHER servlet, and uses the callMethod
> feature (as
> illustrated in main), it doesn't work "as expected".
> The _dirty flag will be set inside of the proxy class, and
> not inside of the
> actual "real" servlet, making using the method effectively impossible.
> So, any code that uses self for anything (which is a lot,
> IMO) won't work.
> I realize that this whole concept is something of a hack, but
> I think it's a
> valuable one, and I just want to explore this.
> This sf.net email is sponsored by:ThinkGeek
> Welcome to geek heaven.
> Webware-devel mailing list