Unicode fix reverted but can have custom validator
MongoEngine/mongoengine#136
This commit is contained in:
parent
6f0a6df4f6
commit
e6d796832e
@ -4,7 +4,7 @@ Changelog
|
|||||||
|
|
||||||
Changes in 0.7.X
|
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)
|
- Allow Django AuthenticationBackends to work with Django user (hmarr/mongoengine#573)
|
||||||
- Fixed reload issue with ReferenceField where dbref=False (MongoEngine/mongoengine#138)
|
- Fixed reload issue with ReferenceField where dbref=False (MongoEngine/mongoengine#138)
|
||||||
|
|
||||||
|
@ -1344,7 +1344,7 @@ class BaseDocument(object):
|
|||||||
return self.__unicode__()
|
return self.__unicode__()
|
||||||
else:
|
else:
|
||||||
return unicode(self).encode('utf-8')
|
return unicode(self).encode('utf-8')
|
||||||
return unicode('%s object' % self.__class__.__name__)
|
return '%s object' % self.__class__.__name__
|
||||||
|
|
||||||
def __eq__(self, other):
|
def __eq__(self, other):
|
||||||
if isinstance(other, self.__class__) and hasattr(other, 'id'):
|
if isinstance(other, self.__class__) and hasattr(other, 'id'):
|
||||||
|
@ -118,11 +118,8 @@ class URLField(StringField):
|
|||||||
|
|
||||||
def validate(self, value):
|
def validate(self, value):
|
||||||
if not self.url_regex.match(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:
|
if self.verify_exists:
|
||||||
warnings.warn(
|
warnings.warn(
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import with_statement
|
from __future__ import with_statement
|
||||||
import datetime
|
import datetime
|
||||||
import os
|
import os
|
||||||
@ -199,9 +200,6 @@ class FieldTest(unittest.TestCase):
|
|||||||
link.url = 'http://www.google.com:8080'
|
link.url = 'http://www.google.com:8080'
|
||||||
link.validate()
|
link.validate()
|
||||||
|
|
||||||
link.url = u'http://президент.рф'
|
|
||||||
self.assertTrue(link.validate())
|
|
||||||
|
|
||||||
def test_int_validation(self):
|
def test_int_validation(self):
|
||||||
"""Ensure that invalid values cannot be assigned to int fields.
|
"""Ensure that invalid values cannot be assigned to int fields.
|
||||||
"""
|
"""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user