diff --git a/docs/changelog.rst b/docs/changelog.rst index 996b5ebd..b749ca2b 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -4,7 +4,7 @@ Changelog Changes in 0.7.X ================ -- Updated URLField - can handle unicode and custom validator (MongoEngine/mongoengine#136) +- Updated URLField - can have a custom validator (MongoEngine/mongoengine#136) - Allow Django AuthenticationBackends to work with Django user (hmarr/mongoengine#573) - Fixed reload issue with ReferenceField where dbref=False (MongoEngine/mongoengine#138) diff --git a/mongoengine/base.py b/mongoengine/base.py index 2044d630..342b31ec 100644 --- a/mongoengine/base.py +++ b/mongoengine/base.py @@ -1344,7 +1344,7 @@ class BaseDocument(object): return self.__unicode__() else: return unicode(self).encode('utf-8') - return unicode('%s object' % self.__class__.__name__) + return '%s object' % self.__class__.__name__ def __eq__(self, other): if isinstance(other, self.__class__) and hasattr(other, 'id'): diff --git a/mongoengine/fields.py b/mongoengine/fields.py index 3dc67490..01d3fc63 100644 --- a/mongoengine/fields.py +++ b/mongoengine/fields.py @@ -118,11 +118,8 @@ class URLField(StringField): def validate(self, value): if not self.url_regex.match(value): - scheme, netloc, path, query, fragment = urlparse.urlsplit(value) - try: - netloc = netloc.encode('idna') # IDN -> ACE - except UnicodeError: # invalid domain part - self.error('Invalid URL: %s' % value) + self.error('Invalid URL: %s' % value) + return if self.verify_exists: warnings.warn( diff --git a/tests/test_fields.py b/tests/test_fields.py index 528f2a16..98065501 100644 --- a/tests/test_fields.py +++ b/tests/test_fields.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- from __future__ import with_statement import datetime import os @@ -199,9 +200,6 @@ class FieldTest(unittest.TestCase): link.url = 'http://www.google.com:8080' link.validate() - link.url = u'http://президент.рф' - self.assertTrue(link.validate()) - def test_int_validation(self): """Ensure that invalid values cannot be assigned to int fields. """