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: 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).
return {}
from django.contrib import admin
class SessionAdmin(admin.ModelAdmin):
@@ -368,28 +368,6 @@ def save_base(self, raw=False, cls=None, force_insert=False,
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:
setattr(self, f.attname, f.to_python(getattr(self, f.attname, f.get_default())))
except validators.ValidationError, e:
error_dict[] = e.messages
invalid_python[] = 1
for f in self._meta.fields:
if in invalid_python:
errors = f.validate_full(getattr(self, f.attname, f.get_default()), self.__dict__)
if errors:
error_dict[] = errors
return error_dict
def _collect_sub_objects(self, seen_objs, parent=None, nullable=False):
Recursively populates seen_objs with all objects related to this
@@ -160,29 +160,6 @@ def unique(self):
return self._unique or self.primary_key
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.')]
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().
def set_attributes_from_name(self, name): = name
self.attname, self.column = self.get_attname_column()
@@ -750,9 +727,6 @@ def __init__(self, *args, **kwargs):
def get_manipulator_field_objs(self):
return [oldforms.EmailField]
def validate(self, field_data, all_data):
validators.isValidEmail(field_data, all_data)
def formfield(self, **kwargs):
defaults = {'form_class': forms.EmailField}
@@ -829,9 +803,6 @@ def get_manipulator_field_objs(self):
def get_internal_type(self):
return "IPAddressField"
def validate(self, field_data, all_data):
validators.isValidIPAddress4(field_data, None)
def formfield(self, **kwargs):
defaults = {'form_class': forms.IPAddressField}
@@ -877,9 +848,6 @@ def get_manipulator_field_objs(self):
def get_internal_type(self):
return "PhoneNumberField"
def validate(self, field_data, all_data):
validators.isValidPhone(field_data, all_data)
def formfield(self, **kwargs):
from import 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.