On Sun, Oct 11, 2009 at 09:50, Jon <[email protected]> wrote:
>
> I'd like to only rollback certain changes in a session. I imagine this
> means using multiple sessions (i.e. start a new session whenever there
> is a new block of work that could be rolled back). However, I'm not
> sure how I could do this; how can I solve the following scenario where
> I have entity dependencies:
>
> myentity.name = "changed" # edit an entity, not yet committed
> myentity.dependency.name = "changed" # changed an entity inside an
> entity, still not committed
>
> I now want to cancel the second change, which may have happened any
> number of times. session.rollback will remove all changes, so I need a
> new session in between the two...perhaps.
>
> I feel uncomfortable with sessions because it feels like a global
> (sqlalchemy says it shouldn't be treated that way).

Several points here:
- What I think you are looking for is explicit transactions, like
session.begin()
- AFAIK, you cannot have one particular instance in several sessions
at the same time.
- You *can* use several sessions in Elixir. It's just not the default behavior.

See:
http://www.sqlalchemy.org/docs/05/session.html

for some details.

Hope it helps,
-- 
Gaƫtan de Menten
http://openhex.org

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

Reply via email to