Using a scoped session with a session generator and I didn't want 
expire_on_commit to be False for everything, so setting it using the 
Session constructor wouldn't work properly. If a session was created prior 
to the one that needed that flag, it'd give me a ProtocolError since it 
couldn't change the session after it'd already been created. Manually 
setting the expire_on_commit attribute in the session and setting it back 
after it was done worked fine, though, and didn't mess with the scoped 
session pool:

    with db_session() as db:
        db.expire_on_commit = False
        # do stuff
        db.expire_on_commit = True

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to