mx.DateTime fixes tls-sprint
authorAurelien Campeas <aurelien.campeas@logilab.fr>
Mon, 20 Apr 2009 19:53:59 +0200
branchtls-sprint
changeset 1408 6bf19f175ea5
parent 1407 75863d3ffd9b
child 1409 f4dee84a618f
mx.DateTime fixes
server/sqlutils.py
--- a/server/sqlutils.py	Mon Apr 20 19:53:28 2009 +0200
+++ b/server/sqlutils.py	Mon Apr 20 19:53:59 2009 +0200
@@ -218,6 +218,16 @@
                         value = crypt_password(value)
                 elif isinstance(value, Binary):
                     value = self.binary(value.getvalue())
+                # XXX <3.2 bw compat
+                elif type(value) is DateTimeType:
+                    warn('found mx date time instance, please update to use datetime',
+                         DeprecationWarning)
+                    value = datetime(value.year, value.month, value.day,
+                                   value.hour, value.minute, int(value.second))
+                elif type(value) is DateTimeDeltaType:
+                    warn('found mx date time instance, please update to use datetime',
+                         DeprecationWarning)
+                    value = timedelta(0, int(value.seconds), 0)
             attrs[SQL_PREFIX+str(attr)] = value
         return attrs