On Sunday 24 December 2006 15:13, wavydavy wrote:
On Dec 23, 12:52 pm, "Italo Maia" <[EMAIL PROTECTED]> wrote:
> How do i make my CalendarDatePicker to show non-Us dates? I saw in the
> trac that someone patched it, but i have found no doc on how to use
> it. patch:http://trac.turbogears.org/turbogears/ticket/330
>
>From memory, you need to specifiy the date format in both the Widget
and an explicit validator, as CalendarDatePicker doen't allow you to
set the format attribute via __init__, or its default validator's
format. Best way IMO is to sublcass the DatePicker, something like:
date_format = "%d/%m/%Y" # or "%Y-%m-%d" or whatever in useful global
class ProjectDatePicker(widgets.CalenderDatePicker):
format = date_format # can't set this in __init__ currently!
validator = validators.DateConverter(format=date_format)
Works with DateTime variants as well, IIRC. Really, I think you should
be able to just pass format as a parameter to __init__ for the widget
and have pass it on to it's default validator, but there maybe some
other thinking going on that I'm missing.
I think the whole design here is somewhat flawed - as it doesn't work well
with i18n.
The actual problem is, that the DateConverter gets the date_format, but it is
_not_ evaluated if it is a callable, but is treated as string.
So, the "trick" to pass locale-dependend parameters as callables won't work.
I've created a patch for both classes for my local TG-version (there are some
other minor modifications).
I see if I can get around submitting a patch.
Diez
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"TurboGears" 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/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---