One of the old Pyramid tutorials has a load_database function that manually commits a transaction that way. That particular function worked correctly as intended, but it's easy to interpret as "use transaction.commit() in Pyramid when you'd use Session.commit() in Pylons". I'm not saying it should be read that way, just that it appears similar enough that it's an easy trap to fall into, and a few days ago I had the same issue.
neurino, in regards to your original post, I highly recommend Mike Orr's Akhet package if you're making the move from Pylons to Pyramid: http://docs.pylonsproject.org/projects/akhet/dev/ It gives a consistent way to structure Pyramid applications that works well for Pylons users. It uses pyramid_tm to manage transactions, so transactions are committed automatically once the calling handler action returns. Within the model you can still define methods that make use of Session.add(something), Session.delete(somethingelse), and Session.flush() just as you would in Pylons. However, there's no need to manually commit the transaction when using a transaction manager, and it can lead to some unexpected behavior if you do. On Wed, May 18, 2011 at 8:12 AM, Wichert Akkerman <wich...@wiggy.net> wrote: > On 5/18/11 14:28 , neurino wrote: > > now using a default template in Pyramid (pyramid_routesalchemy) I >> define Session as before (except calling it DBSession and adding an >> extension): >> >> DBSession = >> scoped_session(sessionmaker(extension=ZopeTransactionExtension())) >> but in views.py I don't use it directly but instantiate it: >> >> dbsession = DBSession() >> root = dbsession.query(MyModel).filter(...)... >> Why? What are the differences? >> > > There is no difference. DBSession.query is exactly the same as > DBSession().query. If you want to know the details I would recommend to read > the SQLAlchemy documentation. > > > > >> Moreover, what are the differences from Pyramid >> >> import transaction >> ... >> model = MyModel(name=u'root', value=55) >> session.add(model) >> session.flush() >> transaction.commit() >> > > Where do you see that in Pyramid? I would never recommend using > transactions like that. Common practice is to use repoze.tm2 or something > similar to manage your transactions at a higher layer. > > Wichert. > > > -- > You received this message because you are subscribed to the Google Groups > "pylons-devel" group. > To post to this group, send email to pylons-devel@googlegroups.com. > To unsubscribe from this group, send email to > pylons-devel+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/pylons-devel?hl=en. > > -- You received this message because you are subscribed to the Google Groups "pylons-devel" group. To post to this group, send email to pylons-devel@googlegroups.com. To unsubscribe from this group, send email to pylons-devel+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-devel?hl=en.