[Z3-sqlos] Re: Different database connections for different sqlobject containers
Andreas Elvers
andreas at work.de
Mon Nov 7 11:57:13 CET 2005
Sidnei da Silva wrote:
> | Sidnei suggested I look in ConnectionDescriptor for a way to do this,
> | but I couldn't figure out how to access any contextual information from
> | there. Without the context I don't think there's a way to decide
> | between different connections.
>
> If you look again, there's this code:
>
> try:
> ut = zapi.getUtility(IConnectionName, context=context)
> except ComponentLookupError:
> ....
>
> This is where you could hook looking up a different connection. Or
> even changing the getConnection method below. Or even better: if you
> add a local connection, and keep the same name, it will pick your
> local connection in preference to the global one.
>
I did exactly this. I added a local connection, kept the name. But when
zope tries to
queryUtility(IZopeDatabaseAdapter,name,default=None,context=context) it
does not find the local local utility and return None instead.
If I setup a static global rdb connection in configure.zcml then
queryUtility will find it. But it will not find local utilities.
- Andreas
More information about the z3-sqlos
mailing list