Unicode fix reverted but can have custom validator

MongoEngine/mongoengine#136
This commit is contained in:
Ross Lawley 2012-10-01 14:48:53 +00:00
parent 6f0a6df4f6
commit e6d796832e
4 changed files with 5 additions and 10 deletions

View File

@ -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)

View File

@ -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'):

View File

@ -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(

View File

@ -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.
"""