[Zope-dev] Re: zope.sqlalchemy, integration ideas

Brian Sutherland brian at vanguardistas.net
Fri May 30 09:36:18 EDT 2008


On Thu, May 29, 2008 at 07:10:16PM +0200, Martijn Faassen wrote:
> [snip]
> > I'm not sure whether it would be a good idea to wrap this in a session
> > property, or just register it as an adapter. The only other object that
> > would need access to the session (either as a property or through
> > adaption) would be the application instance root object. Something like:
> >
> > @adapter(MyApp)
> > @provider(ISession)
> > def root_session(context):
> >     return context._sessioncontext()
>
> This looks to me like it could be a simple function that looks up a local 
> utility instead:
>
> def session():
>    return component.getUtility(ISessionContext)()
> 
> We get the right context from the site that way. I don't see the point in 
> trying to re-implement local utilities with adapters while zope.component 
> already does something quite similar for you. That said, I still have hope 
> we can used ScopedSession and forgo a utility lookup here, see below...

+lots

Perhaps you may want the utility name as a keyword. I'll also note that
doing it this way does not preclude using the ISession adapter in
future. But, using the ISession adapter now means never being able to
get rid of it again.

> If you don't use the ZODB at all, you could still set up local sites (I'm 
> not sure how hard this is, but it *should* be possible; 

I've done it as a work around to override a global utility forced upon
me. It's not too difficult.

> > We do still need to setup parent pointers though for grok.url and
> > IAbsoluteURL to work. It looks fairly easy to add location information
> > to the containers themselves:
>
> (note that grok.url uses IAbsoluteURL, so we just care about IAbsoluteURL)

I'll note that there is a difference between where things are published
(IAbsoluteURL) and where you should go to find their canonical
representation.

One problem I've found with using IAbsoluteURL and location proxies is
getting the object directly from the database. In this situation you
don't have an LocationProxy and IAbsoluteURL doesn't work.

It's pretty nasty when IAbsoluteURL sometimes works and sometimes
doesn't for what essentially is the same object.

-- 
Brian Sutherland


More information about the Zope-Dev mailing list