[Zope-DB] Can't get DCOracle2 to work with Python in Zope

Bo M. Maryniuck b.maryniuk at forbis.lt
Wed Nov 5 09:25:06 EST 2003

On Wednesday 05 November 2003 16:05, Jim Abramson wrote:
> Not too long ago I found myself needing to use DCOracle2 features in zope's
> py scripts, bypassing the constraints of the standard zope database
> adapter. There is a very very simple way to do it, with external methods:
> from Products.DCOracle2 import DCOracle2
> def useDco2(dco2conn):
>     db = getattr(zdbc,'_v_database_connection')
>     db.register()
>     cur = getattr(db,'cursor')
>     # do whatever you want with the db/cur
>     cur.execute('select 999 from dual')
>     rs = db.fetchall()
>     return rs

This is completely unneeded stuff. Basically, you import DCOracle, but never 
use it. Second, I think you can do something like:

def useDco2():
    db = self.zdbc._v_database_connection.db
    db.cursor.execute('select "foo" from dual')

    return db.fetchall()

Third, you can use plain ZSQLMethods instead of this... But if you want live 
outside ZODB transaction, I think you can have here unexpected surprises, 
such as broken data etc.

P.S. IMHO, External Methods sucks for maintain and long run support.

Regards, Bogdan M.Maryniuck

System programmer, Forbis UAB

More information about the Zope-DB mailing list