Matthew T. Kromer wrote:
> Basically, no.
> You could recode DA's to close the connection at the end of every
> transaction and reopen them on demand, but to the best of my knowledge
> none of the DAs work that way.
> Once a connection object opens its connection it stays open but in the
> object cache of that thread. This gives it both an indeterminate
> lifespan and a fair amount of isolation from other threads -- sadly, the
> thread that you're running your ZMI transaction on. The ZMI cant "see"
> what objects the other threads are using (well you actually CAN program
> that but -- dont! -- you'd most likely break Zope in a severe way
> without intending to)
> Most of the open buttons on database connections are pretty useless --
> they just make the connection open early. Most DA's open a connection
> on demand. For "Most" read "all" because I don't know of one that
> DOESNT work that way.
I'll correct that slightly: Zope DAs usually open the connection
as soon as the connection object is loaded into memory, e.g.
if you look at the folder contents containing the connection
This is not the same as opening the connection on demand,
since demand for a connection will only occur at the time
you actually ask the connection object to execute a query
by calling it.
If a connection object only opens the connection if you actually
run a query, that's "connect on demand" and the way we've
implemented this feature in the mxODBC Zope DA.
The "connect on load" which most other DAs implement can
cause problems in some situations e.g. if the
connection to the database is down or not available
for some reason, but you still want to edit the connection
object via the ZMI.
"Connect on demand" also tends to save resources and plays
well with connections that time out after a while.
> On Jul 13, 2006, at 4:41 AM, Jose Carlos Balderas Alberico wrote:
>> Greetings. I'm having a problem with database connectors, and maybe
>> you can give me a hand.
>> Is there a way to manage the opening and closing of database
>> connectors, apart from doing it from the zope management interface?
>> By this I mean, I want to implement a Python script that checks wether
>> a database connection is open or closed. If it's closed, I'll open it,
>> all coded, without having to click the "Open connection" button.
>> I haven't found info on this. Can you help me out with this?
The DAs will usually have a method which implements this. The
name of the method is DA-dependent, e.g. for the mxODBC Zope DA
it's called .connect() or .lazy_connect() if you want to open
the connection object in "connect on demand" mode.
Professional Python Services directly from the Source (#1, Sep 20 2006)
>>> Python/Zope Consulting and Support ... http://www.egenix.com/
>>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/
>>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/
::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! ::::
Zope-DB mailing list