Am 04.07.2010 um 17:50 schrieb Andrea Crotti:



On 4 Lug, 16:00, "Diez B. Roggisch" <[email protected]> wrote:
You know it if it's not failing ;) but I understand the desire to know
beforehand - all you need to do is a dbsession.flush(). If that's
failing, you get an excpetion.

Unfortunately, that means the ongoing transaction is borked. That's a
sqlalchemy design thing. So the safe way to deal with these things is
the common check-lock-check-create-dance to make sure the transaction
commits.

Diez


Ok good, because in general we have to know if it worked or not...
And what exactly is the common check-lock... in practice code
(sorry I'm not an expert at all in this area)?


if User.get_by(name=name) is None:
   lock_user_table() # you can do that e.g. over sqlalchemy.sql.text
   if User.get_by(name=name) is None:
      User(name=name)
user = User.get_by(name=name)

Diez
--
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?hl=en.

Reply via email to