[SQLObject] TimeValidator from_python method missing?
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: Tom C. <su...@ic...> - 2010-02-08 14:05:46
|
Hi Oleg, 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. Since SOTimeCol already have a timeFormat attribute which seems to be used in exactly the same way as the dateFormat attr for a DateCol, it seems that setting the from_python method on TimeValidator may just have been an oversight, or else there is another reason I am not aware of. If it is an oversight, the small patch attached would allow strings to be used to set TimeCol values just as they are now conveniently usable for setting DateCol values. IWBN if you can have a quick look and see if this can be added to future releases. Cheers, Tom |