[Zope-dev] Re: zope.sqlalchemy

Martijn Faassen faassen at startifact.com
Wed May 7 10:15:52 EDT 2008


Hi there,

Laurence Rowe wrote:
[snip]
> The code would get a session through:
> 
>  >>> Session = getUtility(IScopedSession, 'my-app')
>  >>> session = Session()

The drawback is that this is more typing. You do a utility lookup and an 
instantiation as opposed to simply importing the scoped session when needed:

from myapplication import session

session.query(...)

One topic we ran into during the megrok.kss discussion is doing multiple 
instances of the same application, each writing to a different database. 
   You can't hardcode your database name in your application. I think 
sessions as local utilities would help us solve that problem, right?

What would be nice if we could do the 'from myapp import session' 
pattern and have it use the local utility infrastructure underneath 
somehow... Possible?

Regards,

Martijn



More information about the Zope-Dev mailing list