Hi Jonathan,
It's pyramid_tm -- it will clear the session on commit. It's
counter-intuitive (or at least it was for me) if you've spent a lot of time
with SQLAlchemy and using sessions directly, but you should try flush
instead of commit:
print userInstance.id
DBSession.flush()
print userInstance.id
Then your view will still have access to the userInstance object after
adding/updating it, but pyramid_tm to commit the transaction for you. I
know there's been a lot of discussion about this and there are many other
ways of handling it, but from the perspective of porting Pylons to Pyramid
+ pyramid_tm, swapping out commit() for flush() covers a lot of cases and
still lets you handle IntegrityError and other exceptions.
We should probably move this to the Pylons/Pyramid list if there are more
questions though.
Hope this helps!
Eric
On Tue, Feb 14, 2012 at 2:09 PM, Jonathan Vanasco <[email protected]>wrote:
> my stuff doesn't handle the transaction commit - that's purely
> transaction / pyramid_tm
>
> so i'll look into that code to see if its closing it. great lead,
> thanks.
>
> --
> You received this message because you are subscribed to the Google Groups
> "sqlalchemy" 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/sqlalchemy?hl=en.
>
>
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy" 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/sqlalchemy?hl=en.