Author: Honza_Kral
Date: 2009-06-17 19:31:37 -0500 (Wed, 17 Jun 2009)
New Revision: 11034

Modified:
   django/branches/soc2009/model-validation/django/forms/fields.py
Log:
[soc2009/model-validation] Changed EmailField to use validators

Modified: django/branches/soc2009/model-validation/django/forms/fields.py
===================================================================
--- django/branches/soc2009/model-validation/django/forms/fields.py     
2009-06-18 00:31:18 UTC (rev 11033)
+++ django/branches/soc2009/model-validation/django/forms/fields.py     
2009-06-18 00:31:37 UTC (rev 11034)
@@ -451,20 +451,12 @@
         if not self.regex.search(value):
             raise ValidationError(self.error_messages['invalid'])
 
-email_re = re.compile(
-    r"(^[-!#$%&'*+/=?^_`{}|~0-9A-Z]+(\.[-!#$%&'*+/=?^_`{}|~0-9A-Z]+)*"  # 
dot-atom
-    
r'|^"([\001-\010\013\014\016-\037!#-\[\]-\177]|\\[\001-011\013\014\016-\177])*"'
 # quoted-string
-    r')@(?:[A-Z0-9]+(?:-*[A-Z0-9]+)*\.)+[A-Z]{2,6}$', re.IGNORECASE)  # domain
-
-class EmailField(RegexField):
+class EmailField(CharField):
     default_error_messages = {
         'invalid': _(u'Enter a valid e-mail address.'),
     }
+    default_validators = [validators.validate_email]
 
-    def __init__(self, max_length=None, min_length=None, *args, **kwargs):
-        RegexField.__init__(self, email_re, max_length, min_length, *args,
-                            **kwargs)
-
 try:
     from django.conf import settings
     URL_VALIDATOR_USER_AGENT = settings.URL_VALIDATOR_USER_AGENT


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to