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.

Reply via email to