[Twisted-Python] Simple multiplex-relayer with

Mika Bostrom bostik at stinghorn.com
Mon Nov 29 01:08:15 MST 2004


On Fri, 26 Nov 2004, Jp Calderone wrote:
> On Fri, 26 Nov 2004 11:04:44 +0200, bostik at stinghorn.com (Mika Bostrom) wrote:
> > class RelayMessage(smtp.IMessage):
> >   def __init__(self):
> >     smtp.IMessage.__init__(self)
> >     self.msg =3D []
> > 
> 
>   The above class is the most obvious problem I see here.  Interfaces
>   are not meant to be subclassed in this manner.  What you really want
>   is something more like:

  [codelet snipped]

  Thank you, this was indeed the case. You also gave a a very solid rule
of thumb which will come in handy later on. "Interfaces are not meant to
be subclassed." (Yes, cut short; on purpose, as that will be easier to
remember.)

  Your advice also makes a nice example of how to use smtp module as a
base.
  
>   ESMTP will call getMessageDelivery on its deliveryFactory attribute,
>   now that it isn't None.  On the object it returns, it will call
>   receivedHeader, validateFrom, and validateTo.  And on the object
>   returned by calling the object returned by validateTo, it will pass
>   the contents of the message being delivered, letting you relay it
>   wherever is appropriate.

  This part felt a little like black magic, and my first reaction was
that of a scarred Delphi programmer: smelled a bit like excessive
nesting. Until I get a better grasp of what actually happens beneath the
hood, I'll just consider this a necessary evil.

  However, at least by your example and fixes the actual reception
works. I can carry on experimenting with what/how to do with the mail
from thereon.

>   Hope this helps,

  It certainly did. Thank you so much. I may return to list with
additional questions if your examples and hints have failed to enlighten
me after all.

  Take care,

-- 
 Mika Boström         \-/  "World peace will be achieved
 Bostik at stinghorn.com  X    when the last man has killed
 Software slave       /-\   the second-to-last." -anon?




More information about the Twisted-Python mailing list