Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 788de6b

Browse files
committed
Fixed #8206 -- Removed validate methods of Model and Model fields. They are are unsupported for 1.0 and will be replaced with more complete model validation (refs #6845).
git-svn-id: http://code.djangoproject.com/svn/django/trunk@8348 bcc190cf-cafb-0310-a4f2-bffc1f526a37
1 parent 29a9c34 commit 788de6b

File tree

5 files changed

+4
-231
lines changed

5 files changed

+4
-231
lines changed

‎django/contrib/sessions/models.py‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,7 @@ def get_decoded(self):
6565
# just return an empty dictionary (an empty session).
6666
except:
6767
return {}
68+
69+
from django.contrib import admin
70+
class SessionAdmin(admin.ModelAdmin):
71+
pass

‎django/db/models/base.py‎

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -368,28 +368,6 @@ def save_base(self, raw=False, cls=None, force_insert=False,
368368

369369
save_base.alters_data = True
370370

371-
def validate(self):
372-
"""
373-
First coerces all fields on this instance to their proper Python types.
374-
Then runs validation on every field. Returns a dictionary of
375-
field_name -> error_list.
376-
"""
377-
error_dict = {}
378-
invalid_python = {}
379-
for f in self._meta.fields:
380-
try:
381-
setattr(self, f.attname, f.to_python(getattr(self, f.attname, f.get_default())))
382-
except validators.ValidationError, e:
383-
error_dict[f.name] = e.messages
384-
invalid_python[f.name] = 1
385-
for f in self._meta.fields:
386-
if f.name in invalid_python:
387-
continue
388-
errors = f.validate_full(getattr(self, f.attname, f.get_default()), self.__dict__)
389-
if errors:
390-
error_dict[f.name] = errors
391-
return error_dict
392-
393371
def _collect_sub_objects(self, seen_objs, parent=None, nullable=False):
394372
"""
395373
Recursively populates seen_objs with all objects related to this

‎django/db/models/fields/__init__.py‎

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -160,29 +160,6 @@ def unique(self):
160160
return self._unique or self.primary_key
161161
unique = property(unique)
162162

163-
def validate_full(self, field_data, all_data):
164-
"""
165-
Returns a list of errors for this field. This is the main interface,
166-
as it encapsulates some basic validation logic used by all fields.
167-
Subclasses should implement validate(), not validate_full().
168-
"""
169-
if not self.blank and not field_data:
170-
return [_('This field is required.')]
171-
try:
172-
self.validate(field_data, all_data)
173-
except validators.ValidationError, e:
174-
return e.messages
175-
return []
176-
177-
def validate(self, field_data, all_data):
178-
"""
179-
Raises validators.ValidationError if field_data has any errors.
180-
Subclasses should override this to specify field-specific validation
181-
logic. This method should assume field_data has already been converted
182-
into the appropriate data type by Field.to_python().
183-
"""
184-
pass
185-
186163
def set_attributes_from_name(self, name):
187164
self.name = name
188165
self.attname, self.column = self.get_attname_column()
@@ -750,9 +727,6 @@ def __init__(self, *args, **kwargs):
750727
def get_manipulator_field_objs(self):
751728
return [oldforms.EmailField]
752729

753-
def validate(self, field_data, all_data):
754-
validators.isValidEmail(field_data, all_data)
755-
756730
def formfield(self, **kwargs):
757731
defaults = {'form_class': forms.EmailField}
758732
defaults.update(kwargs)
@@ -829,9 +803,6 @@ def get_manipulator_field_objs(self):
829803
def get_internal_type(self):
830804
return "IPAddressField"
831805

832-
def validate(self, field_data, all_data):
833-
validators.isValidIPAddress4(field_data, None)
834-
835806
def formfield(self, **kwargs):
836807
defaults = {'form_class': forms.IPAddressField}
837808
defaults.update(kwargs)
@@ -877,9 +848,6 @@ def get_manipulator_field_objs(self):
877848
def get_internal_type(self):
878849
return "PhoneNumberField"
879850

880-
def validate(self, field_data, all_data):
881-
validators.isValidPhone(field_data, all_data)
882-
883851
def formfield(self, **kwargs):
884852
from django.contrib.localflavor.us.forms import USPhoneNumberField
885853
defaults = {'form_class': USPhoneNumberField}

‎tests/modeltests/validation/__init__.py‎

Whitespace-only changes.

‎tests/modeltests/validation/models.py‎

Lines changed: 0 additions & 177 deletions
This file was deleted.

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /