Author: phd
Date: 2006-10-30 10:35:17 -0700 (Mon, 30 Oct 2006)
New Revision: 2047
Modified:
SQLObject/branches/0.7-bugfix/docs/News.txt
SQLObject/branches/0.7-bugfix/sqlobject/col.py
Log:
A patch by michelts <mic...@gm...>: convert timedelta from MySQLdb to time.
Modified: SQLObject/branches/0.7-bugfix/docs/News.txt
===================================================================
--- SQLObject/branches/0.7-bugfix/docs/News.txt 2006-10-30 17:34:42 UTC (rev 2046)
+++ SQLObject/branches/0.7-bugfix/docs/News.txt 2006-10-30 17:35:17 UTC (rev 2047)
@@ -18,6 +18,10 @@
* InheritableSQLObject.selectBy() now correctly handles foreign keys, even
foreign keys from the parent classes.
+* If the DB API driver returns timedelta instead of time (MySQLdb sometimes
+ does this) it is converted to time; but if the timedelta has days an
+ exception is raised.
+
SQLObject 0.7.1
===============
Modified: SQLObject/branches/0.7-bugfix/sqlobject/col.py
===================================================================
--- SQLObject/branches/0.7-bugfix/sqlobject/col.py 2006-10-30 17:34:42 UTC (rev 2046)
+++ SQLObject/branches/0.7-bugfix/sqlobject/col.py 2006-10-30 17:35:17 UTC (rev 2047)
@@ -1114,6 +1114,12 @@
def to_python(self, value, state):
if isinstance(value, datetime.time):
return value
+ if isinstance(value, datetime.timedelta):
+ if value.days:
+ raise validators.Invalid(
+ "the value for the TimeCol '%s' must has days=0, it has days=%d" %
+ (self.name, value.days), value, state)
+ return datetime.time(*time.gmtime(value.seconds)[3:6])
value = super(TimeValidator, self).to_python(value, state)
if isinstance(value, datetime.datetime):
value = value.time()
|