On Mon, 2008-16-06 at 10:43 -0700, iain duncan wrote:
> I am curious as to why in the wiki tutorial it seems that the standard
> way of using SA is now the long form of 
> 
> DBSession.query(Page).filter_by etc
> DBSession.save()
> DBSession.commit()
> 
> instead of the session context approach that is the default in 1.1
> 
> I'm sure there are good reasons so I'd like to hear them. Will there
> perhaps be a switch to get the session context behaviour instead? I
> personally like being able to count on an automatic write after each
> controller method and to be able to use
> 
> Page.query.get(1) etc
> 
> But I realize my db needs are very simplistic.

I got the behaviour I wanted by adding this line in model.__init__.py

# get the mapper from the scoped_session
mapper = DBSession.mapper

and then in model.person.py doing

from tg2_test.model import metadata, mapper

( clobbering the existing mapper import ).

IMHO, these would be good additions to have, commented out, in the
startup examples so that people can easily figure out how to get the
behaviour they are most used to. 

I could add those examples if someone would like. I suppose I would need
tg2 commit access though. ( or should I make patch files? )

Thanks
Iain



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears Trunk" 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/turbogears-trunk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to