[Zope-Checkins] CVS: Products/DCOracle2 - CHANGELOG:1.55 SP.py:1.10 db.py:1.12
Matthew T. Kromer
matt@zope.com
Wed, 15 May 2002 11:52:34 -0400
Update of /cvs-repository/Products/DCOracle2
In directory cvs.zope.org:/tmp/cvs-serv9212
Modified Files:
CHANGELOG SP.py db.py
Log Message:
Update to make stored procedures postprocess their results to coerce to
"friendlier" zope types. also added a few implicit lob routines
=== Products/DCOracle2/CHANGELOG 1.54 => 1.55 ===
o Add code to support CLOB and BLOB OUT variables from stored
procedures. Collector # 40
+ o Make Z Oracle Stored Procedure results go thru the same LOB/Date
+ conversion for ZSQL methods in ZOracleDA
Desired Features Not Yet Implemented:
=== Products/DCOracle2/SP.py 1.9 => 1.10 ===
from AccessControl import getSecurityManager
import DCOracle2
+from db import LobLocator, DB
myname = split(__name__,".")[1]
if myname == "ZOracleDA":
@@ -121,6 +122,8 @@
info=None
+ _lobConvert = DB._lobConvert
+
def __init__(self, id, title, connection, procname, acquire, check):
self.id = id
self.title = title
@@ -193,7 +196,8 @@
# Note, this does not do result promotion like the DA query will
# which is probably bad. OracleDates in particular look like
# DateTimes but arent at all the same!
- return apply(self._v_proc,args,kw)
+ results = apply(self._v_proc,args,kw)
+ return self._lobConvert(results)
except:
self._v_proc = None
raise # Reraise error
=== Products/DCOracle2/db.py 1.11 => 1.12 ===
last_call_time=time()
+IMPLICITLOBS=1 # Turn this off to get old LOB behavior
+
class DB(TM):
_p_oid=_p_changed=_registered=None
@@ -231,6 +233,11 @@
# Do we get tuples back in results? should just be lists
#
def _lobConvert(self, result, listtype=type([])):
+ # Mutates result in place, but also returns mutated rsult
+ unconvertlist = 0
+ if type(result) is not listtype:
+ result = [result,]
+ unconvertlist = 1
for i in xrange(len(result)):
t = type(result[i])
if t == listtype: self._lobConvert(result[i])
@@ -238,6 +245,8 @@
result[i] = LobLocator(result[i])
elif t == DCOracle2.dco2.OracleDateType:
result[i] = DateTime.DateTime(str(result[i]))
+ if unconvertlist: result = result[0]
+ return result
# Added for ChrisM (11/13/2000 MTK)
def commit_sub(self, *arg, **kw):
@@ -257,11 +266,20 @@
__allow_access_to_unprotected_subobjects__ = 1
def __init__(self, lob):
+ self.lob = lob
self.read = lob.read
self.write = lob.write
self.trim = lob.trim
self.length = lob.length
- # This would do an implicit LOB read, but its probably bad
- #def __str__(self):
- # return self.read()
+ if IMPLICITLOBS:
+
+ def __str__(self):
+ return self.read()
+
+ def __repr__(self):
+ return "<LobLocator at 0x%08x>" % id(self.lob)
+
+ def __len__(self):
+ return self.length()
+