On Dec 26, 10:15 am, "Denis S. Otkidach" <[EMAIL PROTECTED]>
wrote:

> All modified objects are saved for each transaction and I see no way
> to control this. Am I right? There is a lot of cases when such
> behavior in unacceptable. Is it intended or a bug?

the way around this depends on what you're trying to do.  The code you
pasted is issuing a flush().  Is that what you intended to do ?  A
flush by default does write all pending changes within the session to
the database.  flush() does have the option to flush individual
objects, like this:

session.flush([obj2])

in the above case, you needn't begin/commit your own transaction the
way you're doing; flush() always does everything in its own
transaction if one is not established.  if you do use an actual begin/
commit, commit() does not have the same per-object option as flush and
implies a full flush() - the full contents of the session should be
considered a single transactional unit in most cases.

so, if you just want to remove obj1 from any further flushes, remove
it from the session using session.expunge(obj1).   you're also free to
use multiple sessions, one per each object or group of objects, so
that they may be independently managed.

yet another scenario, you want to use transactions that are
independent of session flushes.  To accomplish this, use engine- or
connection-level transactions, as described in the second half of
http://www.sqlalchemy.org/docs/04/session.html#unitofwork_sql .  in
this case you control the transactions independently of any session
behavior, yet the session still participates (at your choosing) in the
overall transaction.

Hope this helps.
--~--~---------~--~----~------------~-------~--~----~
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