[Zope-DB] DC2Oracle external method problem

Matthew T. Kromer matt@zope.com
Tue, 24 Sep 2002 11:14:49 -0400


Iain Bassam wrote:

>Hi there,
>
>I am encountering a problem trying to use DCOralce2 in an external method. I
>am new to zope and python, so there may be an obvious answer that I'm
>oblivious to.
>
>I have installed DCOracle2 into ....\lib\python\Products\ZOracleDA as per
>windows installation instructions and run the install script. Through zope I
>can create a 'Z Oracle Database Connection' and query a database
>sucessfully. I would however like to create an external method to achieve
>this.
>
>I'm using the simple example in the DCOracle2 user guide, however I'm
>getting some errors.
>
>import DCOracle2
>    def dbconnect(self, REQUEST):
>    db = DCOracle2.connect('<user>/<password>@<connect string>')
>    c = db.cursor()
>    c.execute('select * from dual')
>    print c.fetchall()
>
>When I try to create the external method I get the error:
>Error Type: ImportError
>Error Value: No module named DCOracle2
>
>If I copy DCOracle2.py and DCOracle2.c to .../bin/lib directory, which may
>be a hack, I can create the external method, however running it causes the
>following error.
>
>Error Type: AttributeError
>Error Value: 'DCOracle2' module has no attribute 'connect'
>
>Any help as to where I'm going wrong would be greatly appreciated.
>
>regards
>
>Iain
>
>  
>

To use it as an external method; you'll need to pass the connection 
object to your external method -- then just call the connection object 
to get a cursor.

If you wanted to do the connect inside your external method (and thus 
not have the connection object manged by Zope) you want to import the 
inner DOracle2 directory (the one with DCOracle2.py and dco2.pyd).




-- 
Matt Kromer
Zope Corporation  http://www.zope.com/