[Zope-dev] Re: SQLAlchemy integration experiment

Martin Aspeli optilude at gmx.net
Tue Jun 17 03:46:33 EDT 2008


Brian Sutherland wrote:
> On Mon, Jun 16, 2008 at 08:40:24PM +0200, Martijn Faassen wrote:
>> Hi there,
>>
>> In some earlier discussions a number of approaches to integrate SQLAlchemy 
>> into Zope were discussed. Following up on that, I've tried a particular 
>> approach that tries to use ScopedSessions with a custom scope that isn't 
>> just per thread, but also per site (application). The benefit of this 
>> approach is that it should allow the following to just work:
>>
>> from z3c.sa_integration import Session
>>
>> ...
>> def somewhere_in_a_view(self):
>>     session = Session()
>>     return session.query(Test).all()
> 
> For some reason this raises a warning bell in my head. I keep on
> thinking: this is zope, the session is a classic case for a utility, we
> should be getting it in views by an interface.

FWIW, I had the same though.

I think there's a trade-off here: we can use patterns that SQLAlchemy 
and Pylons and others use directly (use a "global" that isn't actually 
global) or we can use patterns that are ubiquitous in Zope (look up 
utilities by interface).

To my mind, the latter is better because it makes us internally 
consistent, and because it promotes one of the formalisms that IMHO 
makes Zope 3 easier to work with.

Martin

-- 
Author of `Professional Plone Development`, a book for developers who
want to work with Plone. See http://martinaspeli.net/plone-book



More information about the Zope-Dev mailing list