On 2/11/07, Honza Král <[EMAIL PROTECTED]> wrote:
>
> is this really necessary ? since you always subclass formsForm, why
> wouldn't you use:
> class PasswordChangeForm(forms.Form):
>     def __init__( self, user, *args, **kwargs ):
>         super(PasswordChangeForm, self ).__init__( *args, **kwargs)
>         self.user = user

Actually, your suggestion was my original approach.

The primary benefit of your suggestion is that it ensures that the
arguments are passed (not as much checking is required in the form).

> I agree that its a little bit more typing, but its also more generic
> and doesn't add functionality that will be left unused in 9 uses out
> of ten.

I agree with your evaluation that it won't be used in 9 out of 10
cases... but that still means a usage rate of 10%.  I do feel that
this is a common usage pattern.

The reason that I make the suggestion is that I found myself using
this functionality (overriding __init__) in a number of places (clear
violation of DRY). Aside from the DRY aspect, I don't like the idea of
asking newbies to override __init__ for a common case.

Also, this functionality has very low overhead... the diff for my
current implementation (without tests or docs) is two lines.

 - Ben

--~--~---------~--~----~------------~-------~--~----~
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?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to