[Zope-dev] Problems with Oracle DA and Dates

Matthew T. Kromer matt@zope.com
Tue, 02 Oct 2001 17:17:17 -0400


Matthew T. Kromer wrote:

> Geir B=E6kholt wrote:
>
>> Hello Dario,
>> Just noticed behaviour similar to this a couple of days ago , but
>> haven't had the time to file a report on it.. - We managed to narrow
>> it down a bit , tho' :
>>
>> In our installation ; Zope silently restarted , quite quickly , and
>> almost unnoticeable to our editors.
>> This was triggered either when we passed one of the
>> oracle-date-objects returned by DCO2 to DateTime(), or when we
>> believed them to be DateTime objects and tried to run DateTime methods
>> on them...
>>
> So what you REALLY want is the ZOracleDA to promote the weakling=20
> dco2.DateTime objects to full Zope DateTime objects.
>
> Aha!
>
> I think that's doable in short order.=20

In fact, here's the simple patch (only the last bit is really necessary,=20
but as long as I was looking at it I tweaked the listtype to be a=20
pseudo-constant as an argument.  I've checked it in to CVS too :)

Index: db.py
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /cvs-repository/Products/DCOracle2/db.py,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- db.py       14 Sep 2001 15:11:19 -0000      1.8
+++ db.py       2 Oct 2001 21:13:58 -0000       1.9
@@ -83,8 +83,8 @@
 #
 ########################################################################=
######
=20
-'''$Id: db.py,v 1.8 2001/09/14 15:11:19 matt Exp $'''
-__version__=3D'$Revision: 1.8 $'[11:-2]
+'''$Id: db.py,v 1.9 2001/10/02 21:13:58 matt Exp $'''
+__version__=3D'$Revision: 1.9 $'[11:-2]
=20
 import DCOracle2, DateTime
 #DCOracle.dbi.dbiDate=3DDateTime.DateTime
@@ -230,12 +230,14 @@
     #
     # Do we get tuples back in results? should just be lists
     #
-    def _lobConvert(self, result):
+    def _lobConvert(self, result, listtype=3Dtype([])):
         for i in xrange(len(result)):
             t =3D type(result[i])
-            if t =3D=3D type([]): self._lobConvert(result[i])
+            if t =3D=3D listtype: self._lobConvert(result[i])
             elif t =3D=3D DCOracle2.dco2.LobLocatorType:
                 result[i] =3D LobLocator(result[i])
+            elif t =3D=3D DCOracle2.dco2.OracleDateType:
+                result[i] =3D DateTime.DateTime(float(result[i]))
=20
     # Added for ChrisM (11/13/2000 MTK)
     def commit_sub(self, *arg, **kw):