[Twisted-Python] Improvements to twisted.protocols.smtp

Moshe Zadka m at moshez.org
Tue Oct 1 05:02:27 EDT 2002


I promised I'll detail my problems with the patch.
I'll try to check something in this weekend, maybe these problems.
 
> Index: twisted/protocols/basic.py

I'd hesitate to touch protocols.basic without a unit test for this
feature.

> Index: twisted/protocols/smtp.py

I have a general problem here: the REs are very complicated and undocumented.
Please use re.X and comment the RE

> -class User:
> +class User(Address):

I'd prefer containment rather than inclusion here.

> -    def __init__(self):
> +    def __init__(self, domain=None, timeout=600):
>          self.mode = COMMAND
>          self.__from = None
>          self.__helo = None
> -        self.__to = ()
> +        self.__to = []
> +        self.timeout = timeout
> +        if not domain:
> +            import socket
> +            domain = socket.getfqdn()
> +        self.host = domain

this is wrong. the domain name should be in the protocol factory, not
in the protocol

> +        self.timeoutID = reactor.callLater(self.timeout, self.timedout)

please allow a timeout of "None" to mean "no timeouts"

> +            del self.__messages
> +        self.sendCode(500, 'Line too long')

this seems like it wouldn't work. the client would send the rest of the long
line, which look like a beginning of a command

>      def do_MAIL(self, rest):
> -        from_ = rest[len("MAIL:<"):-len(">")]
> -        self.validateFrom(self.__helo, from_, self._fromValid,
> -                                              self._fromInvalid)
> +        if not self.__helo:
> +            self.sendCode(503,"Who are you? Say HELO first");

be liberal, at least in the framework. if a user wants to allow
nonusing of helo, he should be free to do this. you can enforce helo
in validateFrom

> -        self.__init__()
> +        self.__from = None
> +        self.__to = []
>          self.sendCode(250, 'I remember nothing.')
what about __messages?






More information about the Twisted-Python mailing list