le 10.05.2007 13:30 TiNo a écrit:
> That still does return mm/dd/yyyy and not dd/mm/yyyy as the default
> value.
> Besides the validator does not work for me that way...
> And if I set the DateConverter(with month_style="dd/mm/yyy"), it
> throws errors for the strings the datePicker gave me...
>
> (side question, how do I get a date through the converter first, and
> through the validator after that? Can I set two validators?)
>
>   
try with the following validator :

class DateConverter(validators.DateTimeConverter):
    def _to_python(self, value, state):
        if value and isinstance(value, datetime.date):
            return value
        try:
            tpl = time.strptime(value, self.format)
        except ValueError:
            raise Invalid(self.message('badFormat', state), value, state)
        return datetime.date(year=tpl.tm_year, month=tpl.tm_mon, 
day=tpl.tm_mday)

and 
data=CalendarDatePicker(name="data",validator=DateConverter(format="%d/%m/%Y"), 
default=datetime.date.today())



--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to