[Zope-Perl] Using persistent DBI handle in PerlExternalMethod

Robin Smidsrød robin@smidsrod.no
Mon, 8 Apr 2002 11:55:51 +0200 (CEST)


If I create a normal Z DBI database connection, is there a way to use this
handle to directly get the corresponding DBI $dbh for that connection?

I would like to use the persistence of Zope to get rid
of connection-penalty, but I need to use the DBI API to be able to
make advanced scripts which calls multiple SQL-statements without the need
to make Z SQL Methods for each one...

I've looked over Zope.pm (zoperl), and taken a small look at the
relevant ZDBI_DA files, but the solution isn't obvious.

Can I use it something like this?

----------------- cut here ----------------------
package ZopeExt::return_something;

use Zope;

# dbi_database_connection is defined in the Zope object tree
# DBH is the field described in the Zope.pm BEGIN sub.
# Is this correct?
my $dbh=$Zope::DBH{'dbi_database_connection'};

my $sth=$dbh->prepare('select * from table');
$sth->execute;

my @row=$sth->fetchrow;

return @row;

1;

---------------- cut here -----------------------