[Twisted-Python] Accessing ClientFactory methods?

Itamar Shtull-Trauring itamar at itamarst.org
Mon Jul 14 12:34:00 MDT 2003


On Mon, 14 Jul 2003 12:53:38 -0500
"Don Hiatt" <don at motorola.com> wrote:

> So this works fine, however, how can I access the echo.sendMsg
> method from outside the class instance? I can't just use
> echo.sendMsg(..) because I never seem to have a "handle" for it. Sorry
> for such a stupid namespace issue, but I am just learning. :) (I have
> tried various ways to get at the method but either get "sendMsg is
> unbounded" or that the method requires an instance to it self). 

This is a design issue I've been wrestling with. One way to do it is
have a method on the factory that the protocol calls in connectionMade
with itself, and then the logic for sending commands to the client is in
the factory.

Another solution is t.i.protocol.ClientCreator, that lets you get back a
Deferred of the protocol instance.

Any other solutions that people have found? I'd like to be able to make
a single, canonical clean way for doing this.

-- 
Itamar Shtull-Trauring    http://itamarst.org/
http://www.zoteca.com -- Python & Twisted consulting




More information about the Twisted-Python mailing list