If I understand aright, You're suggesting calling commit() right after
attempting to create the object, thus:
try:
f = MyClass(name='Binky')
hub.commit()
except:
....
But SQLObject is running in auto-commit mode, so the first statement
commits the (implicit) transaction already--that's what's causing the
exception to be raised. Following it with a hub.commit() would be
redundant, and it would never be executed, anyway, because of the
exception.
Honestly, this is such a classic pattern that I'm surprised it can't be
implemented in TG. At present, I have to check the database for an
object with the same key before attempting to add an new one. :-(
Roger
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/turbogears
-~----------~----~----~----~------~----~------~--~---