"Roger Rohrbach" <[EMAIL PROTECTED]> writes: > 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.
You can do that. What was the problem when you tried it? I used to do that all the time -- and I still do for some exceptions. > 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. :-( I'm shocked that you have to control keys manually... You shouldn't with SQLObject. -- Jorge Godoy <[EMAIL PROTECTED]> --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---

