Kevin Dangoor <[EMAIL PROTECTED]> writes:

> I wouldn't do that as written. You shouldn't change a class attribute
> in __init__. You could change it to self.javascript...

I didn't get it.

> Should the language be assumed to be the same for each visitor and
> each request? I don't think so, in which case setting that is not the
> right solution. Widgets are stateless, which means that each request
> uses the very same widget object. So, dynamic, per-request behavior
> has to happen in the methods that get called on the widget during
> request processing.

It is not assumed to be the same.  Here's how I use it:

        widgets.CalendarDatePicker(attrs = {'size':11, 'maxlength':10},
                                   name = "contrato_assinatura",
                                   format = _("%d/%m/%Y"),
                                   button_text = _(u"Calendário"),
                                   lang = _('pt-utf8'),
                                   labeltext = _('Data de vencimento do 
contrato')),

So, the same way you can mark the format to be translated, you also can mark
the 'lang' that will be used by the calendar.  It tries guessing with
get_locale, but I believe that it will work only on rare cases.

> I'm going to give some thought to making widgets stateful (ie
> instantiated per request) so that people don't get tripped up by that.
> I'm not sure if I can do that without causing minor breakage to
> existing widgets (but, I'll see!)

I believe it will work the way it is since the locale is in the session or is
obtained when the page is requested.

-- 
Jorge Godoy      <[EMAIL PROTECTED]>

Reply via email to