RE: [Twisted-Python] Need some help with my first Twisted program

-----Original Message----- From: twisted-python-bounces@twistedmatrix.com [mailto:twisted-python-bounces@twistedmatrix.com] On Behalf Of Jean-Paul Calderone Sent: Friday, October 19, 2007 5:07 PM To: Twisted general discussion Subject: RE: [Twisted-Python] Need some help with my first Twisted program
On Fri, 19 Oct 2007 16:53:00 -0400, "McCann, Brian" <bmccann@andmore.com> wrote:
[snip]
def openShell(self, trans): ep = EchoProtocol() ep.makeConnection(trans) trans.makeConnection(session.wrapProtocol(ep))
def eofReceived(self): pass
def closed(self): pass
Here, you implemented connection set up, invoking makeConnection on the protocol you instantiated. However, you didn't do anything similar for connectionLost. You may want to keep a list of the protocol instances openShell creates and give them disconnection notification in closed (which is being called in this example).
Jean-Paul
I'm trying various things to do what you suggest, but the Twisted API docs are hard for me to follow sometimes. I tried making "eofReceived" and "closed" just print a debug line (after calling my "connectionLost function didn't appear to do anything), and neither appeared to fire when I closed the ssh client. I tried looking up other examples I could possibly follow on the net, but came up only with the same examples that are on the Twisted site. I can't even figure out where "trans" comes from or what it is :( . Could you point me in the direction of a better example? I assumed that I could find what I needed if I dug hard enough in the API docs, but I just kept reaching dead ends. Thanks for all your help! --Brian

On Fri, 26 Oct 2007 11:41:50 -0400, "McCann, Brian" <bmccann@andmore.com> wrote:
[snip]
Could you point me in the direction of a better example? I assumed that I could find what I needed if I dug hard enough in the API docs, but I just kept reaching dead ends.
The API docs are nice (in places), but nothing really beats diving into the source itself. There are some areas of Twisted which use obscure techniques to achieve a goal, but for the most part the code isn't too hard to follow (and this is improving all the time). If I had the code in front of me again I could probably tell you the particular path I traced up from your code into conch to find a point where it was clear that the "closed" method is what you want to override, but I don't at the moment - but that's all I did, looked at the source, figured out what was called by what, step by step until I found the feature you were interested in. Now, I've used conch before, and maybe even this feature of it, but I didn't consciously remember the answer until I saw it in the code again this time. Previous experience might have guided me a bit in the right direction, but not much beyond that. I might be able to provide some more specific guidance if you're still not finding what you need, but probably not until sometime next week. Jean-Paul
participants (2)
-
Jean-Paul Calderone
-
McCann, Brian