> -----Original Message-----
> From: sqlalchemy@googlegroups.com 
> [mailto:sqlalch...@googlegroups.com] On Behalf Of Eloff
> Sent: 08 September 2009 04:40
> To: sqlalchemy
> Subject: [sqlalchemy] How to bypass scoped_session?
> 
> 
> Hi,
> 
> I'm using scoped_session in my pylons app, but sometimes I have a need
> to create a local session, do a little work, and commit it without
> worrying about the current state of the scoped_session (i.e. without
> committing it)
> 
> I'm having some issues with that because the minute I create a new
> object, it gets associated (as transient I guess?) with the
> scoped_session and barfs when I add it to the local session (object is
> already in a session.)
> 
> The best I've found is expunge() from the scoped_session after init,
> then the add will work without issues.
> 
> Is there any way to create objects without them being added to
> scoped_session? I don't see that there is any way with a regular
> session that they'd be added on init, so it can't be required
> functionality. Maybe there's an option to disable it?
> 
> I can't imagine what it is good for, but that's probably just failure
> of imagination on my part.
> 

Automatically adding objects to a session when they are created is a
feature of Session.mapper (rather than the plain orm.mapper function),
and is deprecated. If you use the plain mapper function, all "root"
objects that you create will have to be explicitly added to a session.
("related" objects will normally be added by default)

Session.mapper also included a couple of extra features (the 'query'
property and a default __init__) which you can recreate yourself using
the examples at
<http://www.sqlalchemy.org/trac/wiki/UsageRecipes/SessionAwareMapper>

Hope that helps,

Simon

--~--~---------~--~----~------------~-------~--~----~
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 
sqlalchemy+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to