[Zope3-dev] getService() call local from global Bug/Hook

Stephan Richter stephan.richter at tufts.edu
Mon May 31 09:25:54 EDT 2004


On Thursday 27 May 2004 18:33, Roger Ineichen wrote:
> If I lookup the principal annotation service
> from the local utility I use:
>
> zapi.getService(self.context, PrincipalAnnotationServiceName)

This should suffice to get you the local or global version based on the 
context. If not, that would be a bug.

> try:
>   aService = zapi.getService(self.context, PrincipalAnnotationServiceName)
> except:
>   aService = zapi.getService(None, PrincipalAnnotationServiceName)

It should never get into the except clause, if you always have a global 
service. And even if the first call raises an exception, the except clause 
will do the same. In either case you can just write:

   aService = zapi.getService(self.context, PrincipalAnnotationServiceName)

Regards,
Stephan
-- 
Stephan Richter
CBU Physics & Chemistry (B.S.) / Tufts Physics (Ph.D. student)
Web2k - Web Software Design, Development and Training



More information about the Zope3-dev mailing list