[Zope3-dev] Re: Bare excepts in z3c.zalchemy

Jürgen Kartnaller juergen at kartnaller.at
Sat Mar 3 03:40:08 EST 2007



Philipp von Weitershausen wrote:
> For the lack of a better mailinglist, I'm posting this to zope3-dev:
> 
> z3c.zalchemy is pretty cool, but the tons of bare except clauses make me 
> a bit uneasy. When I see them, I wonder what this code is expecting to 
> fail and why. Plus, there are no comments as to why a try/except was 
> used in the first place.
> 
> I would offer my help if I knew enough about SQLAlchemy and what kind of 
> things can go wrong in those cases. Either way, I'd feel better using 
> and recommending zalchemy if it didn't have those bare except clauses...
> 
> 

Hi Philip.

datamanager.py: 2 try/except
They are there because it is possible that a table already exists when 
trying to create it or doesn't exist when trying to delete it.
As I remember when I wrote this I couldn't find a better way, but I'm 
there is a better way in the latest version of sqlalchemy.

container.py: 2 try/except
get speaks for itself, it think!
__len__ contains it to be able to view the container even if there is no 
database connection. Otherwise if the database connection is lost you 
even can not view the container in zmi.

So tons == 4 :)

Jürgen



More information about the Zope3-dev mailing list