[Zope-dev] Re: SQLAlchemy integration experiment

Martijn Faassen faassen at startifact.com
Tue Jun 17 05:58:56 EDT 2008


Martin Aspeli wrote:
> Brian Sutherland wrote:
[snip]
>> 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.

The former integrates smoothly with SQLAlchemy. It also is closer to the 
SQLAlchemy documentation. It's also quite likely that someone writing a 
larger application that does use the interface lookup pattern will get 
bored and write something like:

def Session():
    return component.getUtility(ISession)

The Zope component architecture is not about seeing explicit calls into 
it everywhere. That's not the point of it. The point of it is about 
making applications more flexible by allowing people to plug in 
components. My approach allows you to do that.

Anyway, the balance can come out somewhere else. People are free to 
write their own integration approaches, it's just that mine is actually 
  about trying to make exactly this pattern work in the first place. 
Then when I succeed people want it changed. :) Anyway, no surprise: I 
knew that some want other patterns, and I'll be curious to see the other 
approaches as well.

Regards,

Martijn



More information about the Zope-Dev mailing list