[SQL-CVS] r2048 - home/phd/SQLObject/paramstyles/sqlobject
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: <sub...@co...> - 2006-10-30 17:43:42
|
Author: phd Date: 2006-10-30 10:43:20 -0700 (Mon, 30 Oct 2006) New Revision: 2048 Modified: home/phd/SQLObject/paramstyles/sqlobject/col.py Log: Merged patches from the revisions 2047:2047 from the trunk: a patch by michelts <mic...@gm...>: convert timedelta from MySQLdb to time. Modified: home/phd/SQLObject/paramstyles/sqlobject/col.py =================================================================== --- home/phd/SQLObject/paramstyles/sqlobject/col.py 2006-10-30 17:35:17 UTC (rev 2047) +++ home/phd/SQLObject/paramstyles/sqlobject/col.py 2006-10-30 17:43:20 UTC (rev 2048) @@ -1127,6 +1127,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() |