>>>>> "Fabio" == Fabio Tranchitella <[EMAIL PROTECTED]> writes:
Fabio> I fully agree and will apply the patch with the next upload. Fabio> Thanks for your report, patch and explanation. :) Hey, I have forgotten something in my patch. If the connection is down and there isn't DNS server configured, then a socket.error exception will be raise, otherwise if there is DNS server configured, DNS.Base.DNSError will be raise. The patch i have attached to this mail fixes also the second case ;). I tried it and it works, tell me if it works for you... Regards, Arnaud Fontaine
--- validators.py.old 2006-07-16 14:11:26.249788848 +0200 +++ validators.py 2006-07-17 14:13:23.185329064 +0200 @@ -29,6 +29,7 @@ httplib = None urlparse = None socket = None +DNSError = None from interfaces import * from api import * sha = random = None @@ -1130,6 +1131,7 @@ 'empty': 'Please enter an email address', 'noAt': 'An email address must contain a single @', 'badUsername': 'The username portion of the email address is invalid (the portion before the @: %(username)s)', + 'socketError': 'An error occured when trying to connect to the server: %(error)s', 'badDomain': 'The domain portion of the email address is invalid (the portion after the @: %(domain)s)', 'domainDoesNotExist': 'The domain of the email address does not exist (the portion after the @: %(domain)s)', } @@ -1173,7 +1175,19 @@ domain=splitted[1]), value, state) if self.resolve_domain: - domains = mxlookup(splitted[1]) + global socket, DNSError + if socket is None: + import socket + + if DNSError is None: + from DNS.Base import DNSError + + try: + domains = mxlookup(splitted[1]) + except (socket.error, DNSError), e: + raise Invalid( + self.message('socketError', state, error=e), + value, state) if not domains: raise Invalid( self.message('domainDoesNotExist', state,
pgpwcFKiTLD6N.pgp
Description: PGP signature