[ZODB-Dev] question

Shane Hathaway shane at zope.com
Wed Sep 10 11:35:49 EDT 2003


Christian Reis wrote:
> I have a reasonably simple use case that I'd like to share. I'll use as
> an example our UI for creating a sale.
> 
>     We have a sale dialog, in which the user is expected to enter
>     information about a sale being processed. When I open the sale
>     dialog I hand to it a Sale (persistent) instance, which is altered
>     as the user manipulates the interface.

Is the Sale instance actually added to the database before handing it to 
the dialog?  If you added it to the database only after the user has 
clicked "Ok", you wouldn't have a transaction problem.

Alternatively, you might store the Sale instance in a temporary place 
until the user actually confirms the sale.  You might need this if you 
have some kind of "save for later" button on the dialog.

In either case, you can commit or roll back transactions unrelated to 
the sale as needed.  The general pattern is that you should avoid 
long-lived transactions.  A dialog interaction has an unbounded length.

Shane




More information about the ZODB-Dev mailing list