[Zope-CMF] Re: Tools as local utilities

Rocky Burt rocky at serverzen.com
Sun Sep 10 08:56:09 EDT 2006


On Sat, 2006-09-09 at 21:57 +0100, Martin Aspeli wrote:
> Hi guys,
> 
> philiKON pointed out something interesting to me the other day - we 
> could actually register the existing tools as local utilities as of Zope 
> 2.10. That way, you could do this:
> 
>    actions = getUtility(IActionsTool)
> 
> as another spelling for
> 
>    actions = getToolByName(context, 'portal_actions')
> 
> But now we're being more consistent with Zope 3, we are using a proper 
> interface and not just a string to check, we don't have to worry about 
> passing a context parameter (though tests have to do a setSite() call), 
> and we can let the registration be overridden with the component 
> registry operations.

+10 on this idea from me.  The important thing would be to make sure the
getToolByName deprecation message is smart enough to describe the exact
necessary getUtility call.  In other words use "getToolByName(context,
'portal_properties') has been deprecated, please use
getUtility(IPropertiesTool) instead" rather than the confusing
"getToolByName has been deprecated, please use getUtility instead".

- Rocky


-- 
Rocky Burt
ServerZen Software -- http://www.serverzen.com
News About The Server (blog) -- http://www.serverzen.net

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 191 bytes
Desc: This is a digitally signed message part
Url : http://mail.zope.org/pipermail/zope-cmf/attachments/20060910/4224c7ee/attachment.bin


More information about the Zope-CMF mailing list