On Wednesday 23 May 2007 18:18:42 Rick Morrison wrote:
> Isn't this the very thing that the session / UOW constructs are
> supposed to address for case #1?
>
> This can all break in a web application that doesn't want to
> maintain any in-memory state at all -- for those you can serialize
> via
> pickle/JSON/whatever the objects being manipulated and hold them in
> persisent sessions or stashed in the database. When things are as
> you like them, a single flush() in a transaction. The optimistic
> versioning in SA works for protection against other updates.

This is not a web app, but it is sort-of following the 
transaction-per-request pattern, and confirming some child dialog 
will have children changes committed before user confirms or cancels 
the whole thing.

This is not a SAlchemy specific question, i'm asking how people do it 
generaly (although some info on how one can nest transactions in SA 
is needed).

we've invented multiple ways to do it but neither is pretty and 100% 
working - except real nesting transactions. e.g. (optimistic) add all 
things as new and then at cancel try delete them, or (pessimistic) 
try keep changed stuff in memory (and simulate by hand the 
sql-sub-selects over relations).. 
And in worst case the parent-child is a tree, and the levels there are 
unlimited...

> On 5/23/07, svilen <[EMAIL PROTECTED]> wrote:
> > howdy.
> > here the use case.
> > i have object Parent, which has relation to many objects Child.
> >
> > so, in UI, i have dialog editor for the Parent object, which has
> > some direct attributes (name, age, etc), and some list of
> > Children. Adding a Child to the list, or editing attributes of
> > existing child, is done in another (dialog) sub-editor. So there
> > are 2 nested user transactions here - adding/editing a Child, and
> > changing Parent's data.
> > There are 2 possible way to go:
> > - nested, i.e. cancelling parent's editor cancels any changes to
> > parent including adding or editing children data. As result,
> > cancel of parent editor means no changes whatsoever
> > - no nesting, i.e. confirming Child editor saves the child-data
> > and attaches child to parent, and cancelling the Parent editor
> > would not undo any of these. As result, cancel of parent editor
> > means no changes of parent attributes but all changes in
> > relations remain - partial no nesting, when cancelling parent
> > results in child data remain changed, but parent's relation is
> > not changed
> >
> > There are cases when no-nesting/partial-no-nesting is preferred
> > way, but there are cases when nesting is required.
> >
> > add on top of this versioning/bitemporalism and things get
> > tough...
> >
> > Any ideas/patterns how to transfer this
> > nesting-of-user-transactions into DB / alchemy?
> >
> >
> > ciao
> > svil
>
> 


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to