On Mon, Oct 20, 2008 at 12:54:22AM -0700, Sam's Lists wrote: > A few weeks ago I came across a problem catching Integrity Error. > Unfortunately it took me a while to find the workaround. > > http://docs.turbogears.org/1.0/SqlObjectGotchas#id2
The accusation "SqlObject does not catch and re-throw the exceptions of the underlying DB-API module." is simply not true. It was changed long ago. > Can we just export IntegrityError properly? SQLObject catches MySQdb.IntegrityError and rethrows it as dberrors.IntegrityError in mysqconnection.py. If it is not enough - please elaborate. If it's enough - please delete or update the first accusation on that page. PS. Please also update the second accusation. It is true that SQLObject somewhat messes a few different namespaces but it has mechanisms to help the user in this area. First, for most attributes you cannot create a column if there is an attribute or function with the same name: class Test(SQLObject): expire = StringCol() Test.createTable() Traceback (most recent call last): File "./test1.py", line 14, in <module> class Test(SQLObject): File "/usr/lib/python2.5/site-packages/SQLObject-0.10.2-py2.5.egg/sqlobject/declarative.py", line 92, in __new__ cls.__classinit__(cls, new_attrs) File "/usr/lib/python2.5/site-packages/SQLObject-0.10.2-py2.5.egg/sqlobject/main.py", line 784, in __classinit__ cls.sqlmeta.addColumn(column) File "/usr/lib/python2.5/site-packages/SQLObject-0.10.2-py2.5.egg/sqlobject/main.py", line 334, in addColumn % (soClass.__module__, soClass.__name__, name, name)) AssertionError: The class __main__.Test already has a variable or method 'expire', you cannot add the column 'expire' 'dirty' seems to be a rare exception - it is set long after the name clash check. I will add the issue to my TODO. Second, SQLObject allows to have two different names for a column - python name and database name: class Test(SQLObject): _expire = StringCol(dbName="expire") Test.createTable() 1/QueryR : CREATE TABLE test ( id INTEGER PRIMARY KEY, expire TEXT ) Oleg. -- Oleg Broytmann http://phd.pp.ru/ [EMAIL PROTECTED] Programmers don't die, they just GOSUB without RETURN. ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ sqlobject-discuss mailing list sqlobject-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss