[Twisted-Python] Question about ReconnectingClientFactory and conch StatefulTelnetProtocol
mebly5343 at gmail.com
Fri Feb 5 20:29:09 EST 2010
Thanks, Lucas. I spent several hours struggling with this. The source code
DOES make it very obvious. :-) I hadn't realized from the buildProtocol
API documentation that it assigned the factory attribute to the protocol
instance. It's so obvious now... :-)
And, now, I understand the "magic" of assigning the protocol to a factory
which I did not before.
It runs fine!
On Fri, Feb 5, 2010 at 8:04 PM, Lucas Taylor <ltaylor.volks at gmail.com>wrote:
> On 2/5/10 5:23 PM, Mark Bailey wrote:
> Hi Mark,
> The problem is that you have overridden buildProtocol in your Factory
> and not set the factory attribute on the protocol instance
> (ClusterClient instance has no attribute 'factory').
> buildProtocol is responsible for creating the protocol instance and the
> default implementation takes care of assigning the factory to the protocol.
> see the source for Factory and buildProtocol...it's very concise:
> So something like this should work in your case:
> def buildProtocol(self, addr):
> print 'Connected.'
> p = self.protocol()
> p.factory = self
> return p
> This doc is also helpful for understanding the relationship between
> Protocols and Factories:
> It may be worth emphasizing that there's no real magic going on
> here...you're just assigning a python object as an attribute of the
> protocol instance.
> Twisted-Python mailing list
> Twisted-Python at twistedmatrix.com
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Twisted-Python