[Twisted-Python] clients with parameters

Hi, got a quick question. With any client where the __init__() method takes some parameters, (i.e. FTPClient, TOCClient, etc), how can I use the connectTCP/factory mechanisms and also pass it the parameters from the main program? I started with this: if __name__ == "__main__": config = {} # configuration is loaded into this fact = AIMFactory(config['nick'], config['password']) reactor.connectTCP(config['server'], config['port'], fact) class AIMFactory(protocol.ClientFactory): protocol = AIM def __init__(self, nick, password): self.nick = nick self.password = password # etc class AIM(toc.TOCClient): def __init__(self): """ I don't have access to the factory here so I don't know these parameters... """ toc.TOCClient.__init__(self, username, password) This is probably all wrong, and I guess the factory isn't a good place for those parameters to be. But I have a configuration file that I read into a structure and I want to use those options. I looked at the ClientCreator which kind of does what I need but I'd still like to have the factory for other things like logging. Actually, I dont think I'll ever create more than one instance of the client, so I could just use that, but I'd like to know the "right" way of doing this. Thanks, Konrad Rokicki

On Wed, Mar 19, 2003 at 10:50:12PM -0500, Konrad Rokicki wrote:
You need to override the buildProtocol method of your Factory; it must create and return the Protocol instance. See twisted.protocols.toc.TOCFactory, for example. -- Twisted | Christopher Armstrong: International Man of Twistery Radix | Release Manager, Twisted Project ---------+ http://twistedmatrix.com/users/radix.twistd/

On Wed, Mar 19, 2003 at 10:50:12PM -0500, Konrad Rokicki wrote:
You need to override the buildProtocol method of your Factory; it must create and return the Protocol instance. See twisted.protocols.toc.TOCFactory, for example. -- Twisted | Christopher Armstrong: International Man of Twistery Radix | Release Manager, Twisted Project ---------+ http://twistedmatrix.com/users/radix.twistd/
participants (2)
-
Christopher Armstrong
-
Konrad Rokicki