Tres Seaver wrote:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Rocky Burt wrote:
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.

+1 here, too.  In fact, being able to make this switch is the *reason*
'getToolByName' was introduced in the first placey.

:)

 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".

I think we are likely to modify 'getToolByName' to use a registry of
names to utility interfaces for all the "known" names, falling back to
getattr only for unknown ones.  In that case, the deprecation message
can supply either the name of the interface, or at least say that the
name is not a "known" tool name.

+1

As part of this evolution, it'd be useful to take another pass at updating the interfaces interfaces/_tools.py and elsewhere. Quite often, I find that they document the 'get' methods but not the 'set' methods, and that they omit things like getId() which are actually needed (e.g. the ITypeInformation interface omits getId() even though it has a very useful purpose...unless I'm missing something).

Martin

_______________________________________________
Zope-CMF maillist  -  Zope-CMF@lists.zope.org
http://mail.zope.org/mailman/listinfo/zope-cmf

See http://collector.zope.org/CMF for bug reports and feature requests

Reply via email to