I think the answer is in the getToolByName
code ( http://svn.zope.org/Products.CMFCore/trunk/Products/CMFCore/utils.py?view=markup ). This method does this:
- as the first attempt, he tries to get the desired tool by looking at the interface with
getUtility
and including it in the context (which seems good to me) - as a backup, he is trying to directly get the tool from the original context.
Thus, the only way to βmanage all of themβ is as follows: getToolByName
But, as @keul said, caching is also involved and see here ( http://collective-docs.readthedocs.org/en/latest/misc/context. html # itools-interface ) that using the ITools interface when it is not interrupted due to tools that do not yet implement this interface is faster.
For the reasons above, in the end I would suggest:
- ITools (faster)
- getToolByName (safer)
(since direct receipt has already been verified by getToolByName, if it fails, you will not have more luck)
source share