Let's return to this subject, which was discussed a couple of weeks
ago. Here's my latest thinking on the subject.
* Automatic manipulators go away. Instead of messing with those, to
create a new model object you try instantiating it. Validation errors
are raised at that point. Example:
try:
c = Crime(crime_date='2006-1-2', crime_type='theft')
except ValidationError:
print "You have errors."
I dont like this because then form handling view code start to depend on if we are trying to create/modify a model or we have created custom forms. Very artificial. With the current code, I can add a few extra fields in the manipulator returned by AddManipulator()/UpdateManipulator(), or add extra validation function in the view code, which are specific to that view, I do not know how would it be done.
-1
* This plan is nice conceptually because it doesn't leave any chanceIntegrityError is still not ruled out by validation, unless you do things like checking database for uniqueness, and doing it at every setattr is not optimal. It would be best if we just tell users in big bold letters that doing object.save() can lead to integrity error, and you must catch them and do something about them, instead of giving them a false perception that they can do object.save() safely. Developer must pass form data through AddManipulator/UpdateManipulator.get_validation_error(object.__dict__.copy().update(CHANGES)), this is not too much to ask, you have to do it anyways for other forms.
of bad data in any model instance. Currently, Django is "dumb" about
data in model instances -- it allows any arbitrary data there, and
catching bad data is completely the responsibility of the developer.
This can lead to some IntegrityErrors at the database level (search
the django-users mailing list archives for examples) when the
developer forgets to validate.
--
Amit Upadhyay
Blog: http://www.rootshell.be/~upadhyay
+91-9867-359-701
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Django developers" group.
To post to this group, send email to django-developers@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/django-developers
-~----------~----~----~----~------~----~------~--~---