[Zope-DB] catching sql method exceptions inside python scripts

Matthew T. Kromer matt at bane.mi.org
Fri Apr 2 13:39:53 EST 2004


On Apr 2, 2004, at 1:09 PM, Jim Abramson wrote:

> Hi Chris,
>
> Thanks for replying.
>
> Well, the point of the current exercise is a monitoring script that 
> tells me when the
> pool's gone sour - since this doesn't fix itself automatically. I run 
> some simple sql
> and see if anything goes wrong.
>
> The error is this:
>
> (2.6.1)
> Module Shared.DC.ZRDB.DA, line 399, in __call__
>
> 399:        try: DB__=dbc()
> 400:        except: raise 'Database Error', (
> 401:            '%s is not connected to a database' % self.id)
>

Any time you see a string error being raised you should back away 
slowly.  If you move too quickly it will strike.

> I'm no py stud, but I don't think there's any special glove I can use 
> to catch this.
> "except Exception" sure doesn't work. Maybe there is another way?
>
> Perhaps the old hack-the-source ploy. Or is it changed in a more 
> recent release?
>
> Best,
> Jim
>

*MOST* Of the plumbing in Shared.DC.ZRDB is overdue for reevaluation.  
Zope and python have grown up and around this, and it now sits as 
sediment, slowly fossilizing.

This doesn't mean that it should be jettisoned whole cloth, but I 
challenge you to show me the document that details what the contract is 
between Zope, the DA hooks, the DA, and the database driver.   A lot of 
it is implicit in how Shared.DC.ZRDB currently works.  There are 
definite areas where RDBMS concepts like connection pooling or 
"windows" into result sets would be beneficial.  The entire 
error-handling and transaction integration is creaky, some of it just 
nomenclature, other bits missing (but implied) methods, etc.

Unfortunately, it has consistently appeared to me when I've looked at 
the problem in the past, that no simple solution would serve all the 
needs that I can identify -- and lacking any kind of incentive to 
perform the work ... well, there you go.

I believe the DA code predates Zope 2 entirely.




More information about the Zope-DB mailing list