Hello!
On Mon, Feb 08, 2010 at 02:11:00PM +0200, Tom Coetser wrote:
> I'm just wondering if there is a reason why the TimeValidator class in Col.py
> does not also have the from_python method defined to be:
>
> from_python = to_python
>
> as is done for in the DateValidator class?
>
> With this method defined in the DateValidator for example, one can set the
> date for a DateCol field using a string like "2010-01-31", without having to
> first instantiate a datetime.date() instance. The column validators chain
> would take care of converting the string to the correct type for the DateCol,
> depending on the column's dateFormat specification, of course.
>
> But, the TimeValidator does not have the from_python method set like for the
> DateValidator, which means that one can not conveniently use string of the
> format "17:59:20" to set the value for a TimeCol(), and must first create and
> instance of datetime.time() in order to set the TimeCol() value.
Well, that required some thinking. I always wanted to make validators
stricter, much stricter. I don't want to allow StringCol to accept any
value and convert it to a string by calling str(), I don't want BoolCol to
accept any value and convert it by calling bool(), IntCol by calling int()
and so on.
And finally I did it - commit 4117. Validators became stricter though
not yet as strict as I want.
Similarly, I don't want date/time columns to accept strings. On the
other hand date/time validators are bigger and more complex than other
validators. So I decided to make an exception to allow date/time columns to
accept strings and convert them to their proper date/time types.
I committed your patch in the revision 4118. Thank you!
Oleg.
--
Oleg Broytman http://phd.pp.ru/ ph...@ph...
Programmers don't die, they just GOSUB without RETURN.
|