Permalink
Browse files

Fixed #8206 -- Removed validate methods of Model and Model fields. Th…

…ey 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
  • Loading branch information...
gdub committed Aug 14, 2008
1 parent 29a9c34 commit 788de6b5fdef05c1f321868db964ffe31949fbac
@@ -65,3 +65,7 @@ def get_decoded(self):
# just return an empty dictionary (an empty session). # just return an empty dictionary (an empty session).
except: except:
return {} return {}
from django.contrib import admin
class SessionAdmin(admin.ModelAdmin):
pass
View
@@ -368,28 +368,6 @@ def save_base(self, raw=False, cls=None, force_insert=False,
save_base.alters_data = True save_base.alters_data = True
def validate(self):
"""
First coerces all fields on this instance to their proper Python types.
Then runs validation on every field. Returns a dictionary of
field_name -> error_list.
"""
error_dict = {}
invalid_python = {}
for f in self._meta.fields:
try:
setattr(self, f.attname, f.to_python(getattr(self, f.attname, f.get_default())))
except validators.ValidationError, e:
error_dict[f.name] = e.messages
invalid_python[f.name] = 1
for f in self._meta.fields:
if f.name in invalid_python:
continue
errors = f.validate_full(getattr(self, f.attname, f.get_default()), self.__dict__)
if errors:
error_dict[f.name] = errors
return error_dict
def _collect_sub_objects(self, seen_objs, parent=None, nullable=False): def _collect_sub_objects(self, seen_objs, parent=None, nullable=False):
""" """
Recursively populates seen_objs with all objects related to this Recursively populates seen_objs with all objects related to this
@@ -160,29 +160,6 @@ def unique(self):
return self._unique or self.primary_key return self._unique or self.primary_key
unique = property(unique) unique = property(unique)
def validate_full(self, field_data, all_data):
"""
Returns a list of errors for this field. This is the main interface,
as it encapsulates some basic validation logic used by all fields.
Subclasses should implement validate(), not validate_full().
"""
if not self.blank and not field_data:
return [_('This field is required.')]
try:
self.validate(field_data, all_data)
except validators.ValidationError, e:
return e.messages
return []
def validate(self, field_data, all_data):
"""
Raises validators.ValidationError if field_data has any errors.
Subclasses should override this to specify field-specific validation
logic. This method should assume field_data has already been converted
into the appropriate data type by Field.to_python().
"""
pass
def set_attributes_from_name(self, name): def set_attributes_from_name(self, name):
self.name = name self.name = name
self.attname, self.column = self.get_attname_column() self.attname, self.column = self.get_attname_column()
@@ -750,9 +727,6 @@ def __init__(self, *args, **kwargs):
def get_manipulator_field_objs(self): def get_manipulator_field_objs(self):
return [oldforms.EmailField] return [oldforms.EmailField]
def validate(self, field_data, all_data):
validators.isValidEmail(field_data, all_data)
def formfield(self, **kwargs): def formfield(self, **kwargs):
defaults = {'form_class': forms.EmailField} defaults = {'form_class': forms.EmailField}
defaults.update(kwargs) defaults.update(kwargs)
@@ -829,9 +803,6 @@ def get_manipulator_field_objs(self):
def get_internal_type(self): def get_internal_type(self):
return "IPAddressField" return "IPAddressField"
def validate(self, field_data, all_data):
validators.isValidIPAddress4(field_data, None)
def formfield(self, **kwargs): def formfield(self, **kwargs):
defaults = {'form_class': forms.IPAddressField} defaults = {'form_class': forms.IPAddressField}
defaults.update(kwargs) defaults.update(kwargs)
@@ -877,9 +848,6 @@ def get_manipulator_field_objs(self):
def get_internal_type(self): def get_internal_type(self):
return "PhoneNumberField" return "PhoneNumberField"
def validate(self, field_data, all_data):
validators.isValidPhone(field_data, all_data)
def formfield(self, **kwargs): def formfield(self, **kwargs):
from django.contrib.localflavor.us.forms import USPhoneNumberField from django.contrib.localflavor.us.forms import USPhoneNumberField
defaults = {'form_class': USPhoneNumberField} defaults = {'form_class': USPhoneNumberField}
No changes.

This file was deleted.

Oops, something went wrong.

0 comments on commit 788de6b

Please sign in to comment.