Another way would be to add your data configuration to the request object. I do like this at app init:
settings['dataConfig'] = SqlAlchemyConfiguration(settings) Which does metadata management, engine setup etc. And then in the Controller/ "View" or Resource code: dataConfig = self.request.registry.settings['dataConfig'] This object than contains the session, and can be passed to your repository, or used in the spot: self.session = dataConfig.session I personally didn't like to import a module-level global variable like DBSession in the example code. Jasper On 23 May 2011 12:23, neurino <neur...@gmail.com> wrote: > > Creating tables and adding initial content is better done with paster > setup-app or another separate command. > > But setup-app is not present in pyramid. > > I understand your point and I'm also going, in production, to move that > code in a setup script. > > Anyway then, having: > > import transaction > > at the top of my models.py what do I have to take care when adding, merging > or removing content? > > And, back to my initial question: > > in Pylons I had a Session instance named "session" i used in my controllers > like > > model.session.add(anything) > model.session.commit() > > what I'm supposed to do now? > > models.DBSession().add(anything) > > I'm not used to instantiate & call "Class().method" that much and looks me > ugly but if it's the correct way to go with it... > > Thanks for your support > neurino > > > On Mon, May 23, 2011 at 12:08 PM, Wichert Akkerman <wich...@wiggy.net>wrote: > >> Creating tables and adding initial content is better done with paster >> setup-app or another separate command. > > > -- > 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.