On Tuesday 14 August 2007 11:13:37 Mickael Profeta wrote:
> >> I do not really see the problem? validators? Date format for sqlobject?
> >
> > jour = DateCol(alternateID=True)
> >
> > is your problem. It implies a unique-constraint on the DB.
>
> Not exactly. I understand this constraint and I want it.
> The problem is that
>
> try:
> day = Jour.byJour(Date)
> day.texte = Texte
> except SQLObjectNotFound:
> Jour(classe="", jour=Date, texte=Texte)
>
>
> does not work, even if the date is already in the database, it goes to
> the except part....
Sorry, my bad - I didn't read the post carefully enough.
Can you check what actually gets passed as "Date"? If it is a string, it might
be that sqlobject tries and parses that, using the english format.
I found that date validation is a somewhat tricky thing - in my app, I've
occasionally introduced a validator-Schema with validators for the datefields
_again_, and pass that as validators=Schema() to my validate-decorator.
Like this:
class FullOccupancySchema(validators.Schema):
start_date = validators.DateTimeConverter(not_empty=True,
format=i18n.get_date_format)
...
@validate(form=fulldate_occupancy_dialog.form,
validators=FullOccupancySchema())
As you can see, I give both.
HTH,
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
-~----------~----~----~----~------~----~------~--~---