[Zope-dev] DCOracle patch

Christian Scholz cs@comlounge.net
Sun, 2 Jul 2000 16:02:28 +0200


Hi!

I encountered the following bug in the recent DCOracle this week:

When trying to use stored procedures with more than 1 out parameter like

create or replace procedure testproc ( pname out string, pid out int)
AS
BEGIN
    pname:='test1';
    pid:=100;
END;
/   

and calling it from python with

pname,pid= dbc.procedures.testproc()

an exception will be raised:

Traceback (innermost last):
  File "./testcall.py", line 9, in ?
    x= dbc.procedures.testproc()
  File "/opt/python/lib/python1.5/site-packages/DCOracle/ociProc.py", line 149, in __call__
    raise t, v, tb
NameError: t

This is due to the fact that an return from __call__ is only executed when exactly one parameter is returned by Oracle.

I fixed this by adding a line returning the whole tuple.

BTW: The following raise will do the NameError because the variables will only be defined when the for loop is raising an exception. Without the return it was returning from the loop without an exception and thus raise had no valid namespace.


And here is the patch:

Common subdirectories: DCOracle.orig/CVS and DCOracle/CVS
diff -c DCOracle.orig/ociProc.py DCOracle/ociProc.py
*** DCOracle.orig/ociProc.py    Thu Jan 14 18:44:56 1999
--- DCOracle/ociProc.py Sun Jul  2 15:54:27 2000
***************
*** 143,148 ****
--- 143,149 ----
                                  if f is not None: v=f(v)
                          r.append(v)
                      if len(r)==1: return r[0]
+                   return r
                  except: t,v,tb=sys.exc_info()
              raise t, v, tb
          finally: tb=None


Go to your DCOracle directory in site-packages/DCOracle (or the source) and
run

patch -p1 <thispatch

(assuming that you've stored above fragment into 'thispatch').

After this it will also run with stored procedures using two (and more) out parameters.

I've also added it to the bug collector.


regards, 
  Christian


--
COM.lounge                                          http://comlounge.net/
communication & design                                 info@comlounge.net