Re: validating fields with newforms - part 2

2007-11-26 Thread Thomas Güttler
Am Freitag, 23. November 2007 14:37 schrieb Wolfram Kriesing: > this has two drawbacks: > 1) the URL is validated in the "wrong" place (in clean() instead of > clean_url()) > 2) the error, if one occurs, is not assigned to the errors['url'] > but errors['__all__'] > > fixing 2) would also be ha

Re: validating fields with newforms - part 2

2007-11-23 Thread Jonathan Buchanan
On Nov 23, 2007 9:42 AM, Wolfram Kriesing <[EMAIL PROTECTED]> wrote: > > On Nov 23, 2007 3:28 PM, James Bennett <[EMAIL PROTECTED]> wrote: > > > > On 11/23/07, Wolfram Kriesing <[EMAIL PROTECTED]> wrote: > > > looks cleaner in my eyes. opinions please! > > > > In my opinion, you're asking for a lo

Re: validating fields with newforms - part 2

2007-11-23 Thread Wolfram Kriesing
On Nov 23, 2007 3:29 PM, Todd O'Bryan <[EMAIL PROTECTED]> wrote: > > How do you clean a field that's supposed to be a date or a number, for > example, if the user doesn't provide a legal date or number? If you're > not allowed to throw validation errors during cleaning, you could find > yourself i

Re: validating fields with newforms - part 2

2007-11-23 Thread Wolfram Kriesing
On Nov 23, 2007 3:28 PM, James Bennett <[EMAIL PROTECTED]> wrote: > > On 11/23/07, Wolfram Kriesing <[EMAIL PROTECTED]> wrote: > > looks cleaner in my eyes. opinions please! > > In my opinion, you're asking for a lot of custom behavior from a > default field type, and the fact that you have to do

Re: validating fields with newforms - part 2

2007-11-23 Thread Todd O'Bryan
How do you clean a field that's supposed to be a date or a number, for example, if the user doesn't provide a legal date or number? If you're not allowed to throw validation errors during cleaning, you could find yourself in a situation where your later cleaning code makes assumptions that aren't

Re: validating fields with newforms - part 2

2007-11-23 Thread James Bennett
On 11/23/07, Wolfram Kriesing <[EMAIL PROTECTED]> wrote: > looks cleaner in my eyes. opinions please! In my opinion, you're asking for a lot of custom behavior from a default field type, and the fact that you have to do some custom coding to support that custom behavior is not a bug ;) -- "Bu

Re: validating fields with newforms - part 2

2007-11-23 Thread Wolfram Kriesing
We discussed this here again, and it looks like newforms currently mixes cleaning and validating data in a not so ideal way. Actually the clean and validation process should be separated, there should be clean-methods and validate-methods. The process should work in the following way, to allow fu

Re: validating fields with newforms - part 2

2007-11-23 Thread Matthias Kestenholz
On Fri, 2007-11-23 at 14:45 +0100, Wolfram Kriesing wrote: > On Nov 23, 2007 2:41 PM, Matthias Kestenholz <[EMAIL PROTECTED]> wrote: > > > > > > On Fri, 2007-11-23 at 14:30 +0100, Wolfram Kriesing wrote: > > > :-) yep we also discussed that here > > > still it seems "wrong" that it needs to be do

Re: validating fields with newforms - part 2

2007-11-23 Thread Wolfram Kriesing
this has two drawbacks: 1) the URL is validated in the "wrong" place (in clean() instead of clean_url()) 2) the error, if one occurs, is not assigned to the errors['url'] but errors['__all__'] fixing 2) would also be hackish imho wolfram On Nov 23, 2007 2:28 PM, Matthias Kestenholz <[EMAIL P

Re: validating fields with newforms - part 2

2007-11-23 Thread Wolfram Kriesing
But the problem is that the clean() method of the field already throws a validationError, though i actually dont need to validate this field. And that method simply comes first, no way around using the various clean methods :-( wolfram On Nov 23, 2007 2:32 PM, Manakel <[EMAIL PROTECTED]> wrote:

Re: validating fields with newforms - part 2

2007-11-23 Thread Wolfram Kriesing
On Nov 23, 2007 2:41 PM, Matthias Kestenholz <[EMAIL PROTECTED]> wrote: > > > On Fri, 2007-11-23 at 14:30 +0100, Wolfram Kriesing wrote: > > :-) yep we also discussed that here > > still it seems "wrong" that it needs to be done with such a hacky way around > > > > I don't think that's hacky at al

Re: validating fields with newforms - part 2

2007-11-23 Thread Matthias Kestenholz
On Fri, 2007-11-23 at 14:30 +0100, Wolfram Kriesing wrote: > :-) yep we also discussed that here > still it seems "wrong" that it needs to be done with such a hacky way around > I don't think that's hacky at all, really. If you want an URLField, you get a field that guarantees that it really co

Re: validating fields with newforms - part 2

2007-11-23 Thread Manakel
Maybe you can remove the logic from the Field cleanMethod and add it to the Form CleanMethod. because i understand you want a validation based on the content of several fields ? I would try something like this: - in Field "clean" method: validate data nature ie mail address is really a mail adres

Re: validating fields with newforms - part 2

2007-11-23 Thread Wolfram Kriesing
:-) yep we also discussed that here still it seems "wrong" that it needs to be done with such a hacky way around wolfram On Nov 23, 2007 2:28 PM, Matthias Kestenholz <[EMAIL PROTECTED]> wrote: > > Hi Wolfram, > > > On Fri, 2007-11-23 at 14:05 +0100, Wolfram Kriesing wrote: > > I got an alike pro

Re: validating fields with newforms - part 2

2007-11-23 Thread Wolfram Kriesing
this is what i currently have to do :( if the clean_() function would get all the form-data that would no be necessary!! def __init__(self, *args, **kwargs): data = len(args) and args[0] or kwargs['data'] # Copy the data first, so we can modify them, copied = dict([(k,

Re: validating fields with newforms - part 2

2007-11-23 Thread Matthias Kestenholz
Hi Wolfram, On Fri, 2007-11-23 at 14:05 +0100, Wolfram Kriesing wrote: > I got an alike problem, I ran through the docs, mailing lists, etc. > but no solution. > > I got: > > class LinkForm(forms.Form): > TYPE_CHOICES = ( > ('user', _('User link')), > ('url', _('Web link')),

validating fields with newforms - part 2

2007-11-23 Thread Wolfram Kriesing
I got an alike problem, I ran through the docs, mailing lists, etc. but no solution. I got: class LinkForm(forms.Form): TYPE_CHOICES = ( ('user', _('User link')), ('url', _('Web link')), ) type = forms.ChoiceField(choices=TYPE_CHOICES) user = forms.IntegerField(re