>>>>> "Fabio" == Fabio Tranchitella <[EMAIL PROTECTED]> writes:
Fabio> I'm not sure that an exception Invalid is better then a Fabio> socket.error: all in all, there is a problem with the socket Fabio> and the actual behaviour is quite clear in this sense. It would make sense if the upstream author did it like that in the URL class (line 1294 in validators.py). In this class, the error exception is catched and then an Invalid exception is raise with the proper error message. I think it is better to have an exception Invalid because every other exceptions in the validators file are catched and then a Invalid exception is raised. In addition, it is necessary for third application (like turbogears) to use the instance variables provided by this exception. Fabio> Anyway, you missed to attach the patch! :) Sorry, i have attached it to this mail. Fabio> What about talking with upstream about this issue? There is Fabio> nothing debian specific and I would prefer to not apply this Fabio> patch if upstream doesn't agree. I will forward him this patch. Do you see why i think this is a bug in formencode ? Regards, Arnaud Fontaine
--- validators.py.old 2006-07-16 14:11:26.249788848 +0200 +++ validators.py 2006-07-14 10:38:13.947459712 +0200 @@ -1130,6 +1130,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 +1174,16 @@ domain=splitted[1]), value, state) if self.resolve_domain: - domains = mxlookup(splitted[1]) + global socket + if socket is None: + import socket + + try: + domains = mxlookup(splitted[1]) + except socket.error, e: + raise Invalid( + self.message('socketError', state, error=e), + value, state) if not domains: raise Invalid( self.message('domainDoesNotExist', state,