I like the idea.  Perhaps you could have a class method
without_validation() for the bulk upload?

Maniac wrote:
> Adrian Holovaty wrote:
>
> >* Specifically, validation happens on Model.__init__() and
> >Model.__setattr(),
> >
> Ouch... Last time this was discussed this was considered bad thing (I
> may be mistaken) because this doesn't allow any intermediate non-valid
> state for an object which nonetheless may be useful. I mean if you have
> have two fields whose values can only be validated in the presense of
> the other how do you set them if the first __setattr__ blows?
>
> The concept of always keeping object in a correct state is indeed very
> nice but makes some practicle cases really harder. So I would vote for
> late validation on save() or explicit validate().
>
> Or! We can devide all validity checks into two groups and perform
> "basic" validation (like format checking and requiredness) early but
> delay "interesting" validation for moments where all data ready and user
> calls save() or validate().

Or we could have an update() method that took multiple arguments like
the constructor.    If two fields do depend on each other for validity
then it makes sense that you can't set them separately.

> This breaks semantics of a property of an object: you should be able to
> read exactly what you just set. Imagine explaining this magic to a newbie:
>
>     c.crime_date = request.POST['crime_date'] ## user submits '2006-1-2'
>     if c.crime_date == '2006-1-2': ## false!
>         ...
>
> Of course you can define comparision with strings etc... But this leads
> to even more magic.

Isn't this the magic that we explicitly request when we specify a
model?  Is this less confusing:

c.crime_date = request.POST['crime_date'] ## user submits '2006-1-2'
c.crime_date == '2006-1-2' # true
c.save()
c.crime_date == '2006-1-2' # false!

If an attribute is going to be magic it should be consistently magic.
Practicality beats purity here, I think.  In practice you need to be
familiar enough with your models to understand what is happening here
for them to be any use at all.

Kieran


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to