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

JD lists at webcrunchers.com
Thu Jan 8 16:04:18 EST 2004


On Jan 5, 2004, at 7:28 PM, Andrew Bennetts wrote:

> On Mon, Jan 05, 2004 at 06:59:26PM -0800, JD wrote:
>>
>> That's what I thought.   Did you take a look at that code sample I 
>> sent
>> earlier?  I hacked that up myself,  with few examples,  so I can see 
>> where
>> i might have put things in places they weren't intended to be.
>
> I did.  The basic idea seemed fine, except for the trivial flaws I 
> pointed
> out.  I don't have time to test and debug your code for you, though,
> especially when it's obvious you haven't tried to do so either.  If 
> your
> code isn't working, then it would help us if you could specify *how* it
> isn't working, i.e. what error or misbehaviour you are seeing.  Your
> previous mail didn't indicate that you'd tested the example code you 
> sent
> (and the trivial syntax errors suggest this is also the case).

Don't worry about the code....   it was put up there to only show to
general construct,  and how I plan to put things together.   it was a 
simple
lame example totally different then what my intended APP was going to
be,   I just used that just to illustrate to others,  my understanding, 
  or
lack thereof..
>
>>> Also, good style suggests that you probably shouldn't mix your
>>> application
>>> code with your IRCClient extensions, i.e. subclass IRCClient for WHO
>>> support
>>> (and other other unimplemented commands you need), and then subclass
>>> that
>>> for your application.
>>
>> I don't quite understand.   Because in my case,  my application just
>> intantiates a client long enough to extract some information from the 
>> IRC
>> server,  issue a "who" command and extract the data.
>>
>> I always thought it was appropriate to sub-class the part i want to 
>> do, or
>> parts that are not implemented by the parent,  as in my case of 
>> wanting to
>> do the "who" command,  so I treated the command like any other IRC 
>> command
>> that issues commands and gets back data.
>>
>> 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.

John





More information about the Twisted-Python mailing list