Ján ONDREJ (SAL) schrieb:
> Hello,
> 
>   what is a replacement for DBSession.commit() in current TG2 (beta1)?
> In some discussions I found, that I have to use transaction.commit(),
> but it does not work for me:
> 
> UnboundExecutionError: Instance <User at 0xa8d728c> is not bound to a
> Session; attribute refresh operation cannot proceed
> 
> Why I need manual commit:
>   1. I need to commit partial data to use a proper auto_increment
> value later. After commit I can use auto incremented value to store
> more records. I know, that this can be solved by changing my model and
> use interaction between tables.
>   2. One more important thing is to show proper error message. When an
> transaction fails to store (for example because there is another
> unique column in database) I need to know, which error has raised and
> flash proper message. I don't know, how to fix this in general.
> 
> I can remove ZopeTransactionExtension() from mi sessionmaker, but I
> don't know, what it means and how it applies to other TG2 code.
> DBSession.commit is working well without this extension.

You shouldn't use DBSession.commit. Instead, you need DBSession.flush. 
This will send all outstanding SQL to the DB, resulting in the creation 
of ids.

Or, even better, use objects instead of ids. This is of course not 
*always* feasible, e.g. if you want to render a freshly created object's 
id into HTML.

Do not remove the ZTE.

Diez

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears Trunk" 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-trunk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to