Definitely go with middleware--it's very clean and simple. Also, make sure to use sqlalchemy.orm.scoped_session()--it makes using sessions in Django pretty much transparent; any time you need to work with a session, you call Session(), and it either uses your current one, or creates a new one if necessary.
Coincidentally, I actually wrote in that first thread you linked to. :-) -Jeff On Apr 23, 5:30 pm, Michael Trier <[email protected]> wrote: > Hi, > > On Thu, Apr 23, 2009 at 4:05 PM, davidlmontgomery < > > > > [email protected]> wrote: > > > I would like to know if there is a consensus on the best > > way to set up and remove sqlalchemy Sessions in django. > > > I figure I'm either going to use middleware, something like this > > thread: > > >http://groups.google.com/group/django-users/browse_thread/thread/e674... > > > or I'm going to use signals, something like this post: > > >http://translate.google.com/translate?hl=en&sl=ja&u=http://d.hatena.n... > > > Any clear advantages or disadvantages for the two approaches? > > Personally I find the Middleware approach cleaner and allows you to handle > exceptions with rollbacks as indicated in the django-users thread. There > was a project Tranquil (http://code.google.com/p/tranquil/) that expanded on > this idea to inject more stuff into the request automatically. It's pretty > much dead at this point from what I understand. > Additionally I'll point out that I have a project called Django-SQLAlchemy > (http://gitorious.org/projects/django-sqlalchemy) that has the aim of > automatically making SQLAlchemy accessible through Django applications. > > Good luck. > > -- > Michael Trierhttp://michaeltrier.com/http://thisweekindjango.com/ --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
