Adrian Holovaty wrote:
> On 6/7/06, gabor <[EMAIL PROTECTED]> wrote:
>> so now the decisions are already done, and when all the fields will have
>> the necessare to_python (+validate) methods, then save will be changed
>> to call validate, and the task is done?
>>
>> or still some decisions have to be done first?
>>
>> i'm simply asking whether patches should be sent in for the remaining
>> fields....?
>
> Right -- those are the next steps. Thanks for the prodding about this.
> After that, the plan is to remove the automatic manipulators in favor
> of something that uses the validation. See Joseph K.'s e-mail to
> django-developers from a couple of weeks/months ago...
>
i tried to implement the validation-logic for some of the fields, but
while looking at the source code, i found this inconsistency...
question:
========================
class SlugField(Field):
def __init__(self, *args, **kwargs):
kwargs['maxlength'] = kwargs.get('maxlength', 50)
kwargs.setdefault('validator_list', []).append(validators.isSlug)
# Set db_index=True unless it's been set manually.
if not kwargs.has_key('db_index'):
kwargs['db_index'] = True
Field.__init__(self, *args, **kwargs)
=======================
as you see, it sets up the validators.isSlug validator
=======================
class EmailField(CharField):
def __init__(self, *args, **kwargs):
kwargs['maxlength'] = 75
CharField.__init__(self, *args, **kwargs)
<snip/>
def validate(self, field_data, all_data):
validators.isValidEmail(field_data, all_data)
========================
this one does not set up a validator, and does a "manual" validation.
why do they behave differently?
or, better question:
what's the recommended approach:
add validators to the field's validator_list, or remove those and do an
explicit validation in the validate() method?
gabor
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-developers
-~----------~----~----~----~------~----~------~--~---