[z3-five] Re: mechanism to get special nodes
Philipp von Weitershausen
philipp at weitershausen.de
Wed Sep 14 15:26:17 CEST 2005
Janko Hauser wrote:
> Hello, by using Five I encounter sometimes situations, where I get at
> special nodes (like cmftools, or a portal root) by acquisiton. Is there
> a better way to do it more like a getutility() call. Sure I could
> generate an utility, which does the acquisition internally, but that's
> only sugar.
Indeed, most of what would be suggestable is sugar. Even CMF's own
getToolByName() is also just sugar for acquisition right now. And since
tools are persistent it doesn't make sense just yet to have them
registered as Zope 3 utilities. We'll need local site managers for that
which will probably only make sense when we've switched to support Zope
3.1. Then, the preferred way of getting at them could be a getUtility()
call with getToolByName() being syntactic sugar for that as a migration aid.
If you want a "sweeter" way to get at the root, then here's some API
sugar: You could write an IPhysicallyLocatable adapter for
OFS.interfaces.ITraversable (IOW, all SimpleItems). This adapter takes
care of getting at the root, computing the physical path, etc. In the
case of Zope 2 OFS.interfaces.Traversables, it should just delegate to
getPhysicalPath, aq_parent, etc. If you happen to do that, feel welcome
to contribute it back to Five. :)
Philipp
More information about the z3-five
mailing list