[Twisted-Python] AFactory

Glyph Lefkowitz glyph at twistedmatrix.com
Thu Jul 25 11:43:45 EDT 2002


On Thu, 25 Jul 2002 12:53:08 -0300, Zooko <zooko at zooko.com> wrote:
> 
> > The normal idiom here is to have your "userapp" inherit from protocol.Factory.
> > The default "factory" implementation does set itself as an attribute on the
> > protocols it builds...
> 
> Ah!  Of course.  Thanks.
> 
> I tend to prefer other techniques (like AFactory) over inheritance when
> possible, but since inheritance is the Twisted Way, I'll do it that way.  

I agree with you (and I agree even more now than I did when I wrote Factory)
but I think that Factory is one of those instances where "is-a" makes sense, if
not inheritance.  Really the way I'd do it now, starting from scratch, would be
to have an interface which you either implement or provide an adapter for, that
had the buildProtocol/doStart etc methods on it.

The reason I say that is that the extra level of indirection (in AFactory)
doesn't really provide for any interesting hooks; the object that is "building"
the protocols is typically your user application.  protocol.Factory is more
like an interface that it implements than a class it should inherit from, but
it does have the utility convenience of (doStart and doStop) -> (startFactory
and stopFactory).

As far as that doc goes... yes.  We need it.

-- 
 |    <`'>    |  Glyph Lefkowitz: Traveling Sorcerer   |
 |   < _/ >   |  Lead Developer,  the Twisted project  |
 |  < ___/ >  |      http://www.twistedmatrix.com      |
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://twistedmatrix.com/pipermail/twisted-python/attachments/20020725/abfd8459/attachment.pgp 


More information about the Twisted-Python mailing list