[Twisted-Python] Re: Where is best place to put my custom code?

Andrew Bennetts andrew-twisted at puzzling.org
Fri Jan 9 11:20:07 EST 2004


On Thu, Jan 08, 2004 at 01:04:18PM -0800, JD wrote:
> On Jan 5, 2004, at 7:28 PM, Andrew Bennetts wrote:
> >On Mon, Jan 05, 2004 at 06:59:26PM -0800, JD wrote:
[...]
> >>
> >>So If I can't mix my application code with a sub_class of a IRCClient,
> >>then how is the right way to do it.
> >
> >What I was trying to say is rather than subclass like this:
> >
> >    IRCClient (from twisted.protocols.irc)
> >     |
> >     \--YourIRCApp (adds WHO command, has your application logic)
> >
> >It might be a better idea to do it like this:
> >
> >    IRCClient (from twisted.protocols.irc)
> >     |
> >     \--ExtendedIRCClient (adds WHO command)
> >         |
> >         \--YourIRCApp (has your application logic)
> 
> I've already decided that....    because when I first started to use
> Twisted,  I had no clue of even the existance of ExtendedIRCClient
> because it was so cleverly mis-labeled and hidden so well in the
> examples,  I never would have found it,  had I not posted this in
> the first place.

You misunderstand me.

I wasn't referring to the AdvancedClient class in sandbox/exarkun/irc2.py,
as you seem to be thinking.  I was offering a suggestion on how to structure
*your* code that extends twisted.protocols.irc.IRCClient, if you choose to
extend it.

(The fact that AdvancedClient is an extension to IRCClient that subclasses
it as I describe above suggests that my advice is sound, but the existence
of AdvancedClient is incidental to the point I was trying to make.)

-Andrew.





More information about the Twisted-Python mailing list