[Twisted-Python] Error handling for modules which use twisted.enterprise.adbapi
vishalshetye at gmail.com
Wed Feb 10 12:28:51 EST 2010
I have an application that uses twisted.enterprise.adbapi for
accessing sqlite database.
Recently I had to replace sqlite3 shipped with python 2.5 with latest
version of pysqlite2. This was for taking advantage of newer fixes in
I thought it would be worthwhile to support both.
However, functions called using runInteraction have a code block as given below.
an errback on the function runQuery/Interaction/Operation. They all
used twisted.python.failure.check/trap on some exception of the form
Now, all such places need to import exceptions from pysqlite2 instead
However, to handle multiple dbapi modules one of which will be
configured for use by the user, I thought, I will have a global name
having reference of the current dbapi module being used. This will be
used by errbacks and except blocks.
Is there a better way of handling exceptions in such cases?
I came across http://svn.sqlalchemy.org/sqlalchemy/trunk/lib/sqlalchemy/exc.py.
I think sqlalchemy wraps dbapi erros in DBAPIError exception.
I imagine doing something similar in twisted as,
I also came across
which suggests exceptions raised by different modules for same type of
error may not be consistent, atleast with respect to the information
Any suggestions on this would be very helpful.
Just to note http://twistedsphinx.funsize.net/projects/core/howto/rdbms.html
does not have error handling related info.
More information about the Twisted-Python