On 2/1/07, Frankie Robertson <[EMAIL PROTECTED]> wrote:
> On 01/02/07, Honza Král <[EMAIL PROTECTED]> wrote:
> > On 2/1/07, Amit Upadhyay <[EMAIL PROTECTED]> wrote:
> > > On 1/31/07, Honza Kr�l <[EMAIL PROTECTED]> wrote:
> > > > what if I have one Form class and want to use it twice in one
> > > > view/template/<form> tag ?
> > > > in that case, prefixes are my only hope... ;)
> > >
> > >
> > > Prefixes are good idea, but implementation is a bit more generic than need
> > > to. As of now either prefix will be *added* before the id
> >
> > which should be enough for 90% of cases
> >
> > or you have to
> > > override a method for allowing other formatting,
> >
> > which is very easy to do
> >
> > python's string formatting
> > > is not used in prefix. Should be.
> >
> > why? for the 10%, I think (at least some) people will be confused when
> > they HAVE to pass something with python format strings in it in order
> > for it to work, many will forget and complain that it's broken. The
> > situation now allows for maximum flexibility while allowing for very
> > easy use when only basic distinction is needed. That is IMHO a good
> > thing.
>
> First, please allow me to try and clear up what I was talking about. I
> was thinking of having something like form_object.prefix_format =
> "%s-%s" by default and that value could be changed. Nobody is saying
> that this would be done by passing a compulsory string formatting
> argument to __init__. Can you please not make assumptions about what
> people are saying? As for your previous post, I agree, prefixes are
> obviously a good thing.
oops, my mistake. sorry.
> The only advantage of add_prefix() I can think of at the moment is
> that it allows the prefix to come after the the field name. If it
> doesn't just use a formatting string and the value it produces changes
> in between form generation and submission then unpredictable errors
> will happen. Could someone could come up with a situation in which the
> method would be more useful than the property, other than the prefix
> having to be a suffix?
perhaps when used like this, the property will also work for suffixes
(although it makes the word prefix misleading):
PREFIX_MASK = '%(prefix)s-%(field_name)s'
def add_prefix(self, field_name):
"""
Returns the field name with a prefix appended, if this Form has a
prefix set.
Subclasses may wish to override.
"""
return self.prefix and ( PREFIX_MASK % { 'prefix' :
self.prefix, 'field_name' : field_name }) or field_name
>
> >
> > >
> > > --
> > > Amit Upadhyay
> > > Blog: http://www.rootshell.be/~upadhyay
> > > +91-9820-295-512
> > > >
> > >
> >
> >
> > --
> > Honza Kr�l
> > E-Mail: [EMAIL PROTECTED]
> > ICQ#: 107471613
> > Phone: +420 606 678585
> >
> > >
> >
>
>
> --
> http://grimboy.co.uk
>
> >
>
--
Honza Král
E-Mail: [EMAIL PROTECTED]
ICQ#: 107471613
Phone: +420 606 678585
--~--~---------~--~----~------------~-------~--~----~
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?hl=en
-~----------~----~----~----~------~----~------~--~---