>> I need to make a query before saving to check if the unique costraint >> is violated? In my opinion a best solution is a way to trap the >> dberror and show an error message to the users >> > no you need to "flush to the db" in tg2 this is done by issuing > transaction.commit(), which together with other things calls > DBSession.flush()
This is not correct. At least the "no you need" (which I presume you mean "you don't need") part. Because of the lazyness of SQLAlchemy, a mapped object won't get an ID until the next flush. As you correctly state, this is eventually done implicitly by the commit. But often enough when you create an object, you want to e.g. render a page containing it's ID - and thus you need to call flush. 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 -~----------~----~----~----~------~----~------~--~---

