[Zope-Checkins] CVS: Products/DCOracle2/DCOracle2 - DCOracle2.py:1.80
Matthew T. Kromer
matt@zope.com
Fri, 8 Feb 2002 11:03:36 -0500
Update of /cvs-repository/Products/DCOracle2/DCOracle2
In directory cvs.zope.org:/tmp/cvs-serv31806
Modified Files:
DCOracle2.py
Log Message:
Back out AI patches
=== Products/DCOracle2/DCOracle2/DCOracle2.py 1.79 => 1.80 ===
import types
import time
-from string import split, join, upper, find, replace
+from string import split, join, upper, find
version = "$Revision$" [11:-2] + " (dco2: %s %s)" % (
dco2.__version__, dco2.buildDefs)
@@ -53,7 +53,11 @@
paramstyle = 'numeric' # We do 'named' too
DEFAULTPROCSIZE=256
-DEFAULTSIZE_SQL_STR=32000
+
+DateConversion = [None,]
+
+def registerDateConversion(x):
+ DateConversion[0] = x
def connect(dsn=None, user=None, password=None, database=None):
@@ -652,7 +656,6 @@
arraysize = 200
rowcount = -1
description = None
- _fetch_out_of_sequence = 0
__allow_access_to_unprotected_subobjects__ = 1 # For Zope
def __init__(self, c, connection):
@@ -738,8 +741,6 @@
if self._cursor is None:
raise InterfaceError,"cursor is closed"
- self._fetch_out_of_sequence = 0
-
if operation is None: operation = self._operation
if self._operation != operation or self._nullmap is None:
@@ -799,21 +800,7 @@
else:
self._cursor.bindbyname(ck, p)
- # AI-Patch: Workaround for oracle error ORA-0468 after
- # updating of existing packages or procedures
- # via "create or replace package..." without restarting
- # the python script.
- #
- # [MK -- does the procedure need to be redescribed?]
- try:
- result = self._cursor.execute()
- except dco2.DatabaseError, e:
- # ORA-0468: exsting state of packages has been discarded
- if int(e[0])== 4068:
- result = self._cursor.execute() # Try again
- else:
- raise
-
+ result = self._cursor.execute()
self.rowcount = self._cursor.rowcount()
self.description = self.describe()
if result == 8:
@@ -832,10 +819,6 @@
def executemany(self, operation, params):
if self._cursor is None:
raise InterfaceError,"cursor is closed"
-
- # AI-Patch: mark that we haven't fetched any result yet
- self._fetch_out_of_sequence = 0
-
prepared = 0
if self._operation != operation:
self._cursor.prepare(operation)
@@ -964,16 +947,7 @@
def fetchone(self,skip=0):
if self._cursor is None:
raise InterfaceError,"cursor is closed"
-
- # AI-Patch: after we have once detected that there
- # no more data, return directly None
- if self._fetch_out_of_sequence:
- return None
-
- # AI-Patch: only clear the buffer when we have passed all results
- # and when the result buffer was completely filled
- # <self._rcount==self.arraysize>
- if self._result is not None and self._rcount >= len(self._result[0]) and self._rcount==self.arraysize:
+ if self._result is not None and self._rcount >= len(self._result[0]):
self._result = None
self._rcount = -1
@@ -998,17 +972,18 @@
try:
v = col[self._rcount].value()
except IndexError:
- # AI-Patch: Mark the end of data so that we don't
- # try to fetch again data out of the cursor
- # which could result in hanging cursors in a
- # multithreading environment
- self._fetch_out_of_sequence = 1
self._result = None
return None
# Note that if we got back a dco2.cursor, we need to wrap it
- if type(v) == type(self._cursor):
+ t = type(v)
+
+ print DateConversion
+
+ if t == dco2.CursorType:
v = cursor(v)
v.description = v.describe()
+ elif t == dco2.OracleDateType and DateConversion[0]:
+ v = DateConversion[0](v)
l.append(v)
@@ -1176,15 +1151,7 @@
#print "Binding argument %s= %s" % (v, keymap[v])
else:
if len(args) <= argsused:
-
- # AI-Patch: Handling optional IN-Parameters
- # for stored procedures by ignoring missing
- # params and inform user.
- # Hmm, should we also check if the params
- # has had a default value??
- #print "DCOracle2> Warning: not enough arguments! Treat them as optional IN param"
- continue
- #raise ValueError, "Not enough arguments"
+ raise ValueError, "Not enough arguments"
argmap.append([args[argsused], d[3][5], d[3]])
#print "Binding argument %s= %s" % (v, args[argsused])
argsused = argsused + 1
@@ -1210,28 +1177,17 @@
# doesn't properly handle IN OUT
if 'OUT' in a[1] and type(a[0]) is not dco2.BindingArrayObjectType:
# BindingArrays are made with count, size, type
- dty = a[2][0]
l = a[2][2]
if cursor is not None:
try:
l = cursor._sizes[i]
except IndexError: pass
- if l is None or l == 0:
- # AI-PATCH: use a greater result buffer
- # for varchar2 out params
- if dty == 1:
- l = DEFAULTSIZE_SQL_STR
- else:
- l = DEFAULTPROCSIZE
-
+ if l is None or l == 0: l = DEFAULTPROCSIZE
# Need to use the setoutputsize parameter
if l == 0:
- # AI-PATCH: use a greater result buffer
- # for varchar2 out params
- if dty == 1:
- l = DEFAULTSIZE_SQL_STR
- else:
- l = DEFAULTPROCSIZE
+ l = DEFAULTPROCSIZE
+
+ dty = a[2][0]
# Based on the data type, we may need to do some special
# transforms (e.g. sending numbers through as strings)
@@ -1351,10 +1307,7 @@
if (desc.has_key(sname) and desc[sname][2] == 'package'):
(schema, uname, type, pdesc) = desc[sname]
-
- # AI-Patch: for python2.2 we need an
- # additional condition <uname==''>
- if uname is None or uname=='': uname = name
+ if uname is None: uname = name
# Set up the package
if self._schema is None: sname = name
else: sname = "%s.%s" % (self._schema, name)
@@ -1436,15 +1389,7 @@
LONG = "long"
FLOAT = "float"
for i in xrange(len(ba)):
-
- # AI-Patch: if you run oracle in a german environment
- # you get a float as string in a german format with
- # a "," for the fraction
- try:
- f = float(ba[i])
- except ValueError:
- f = float(replace(ba[i],",","."))
-
+ f = float(ba[i])
l = long(f)
try:
n = int(f)