[Zope3-Users] Re: looking for something like getUtilitiesFor...
Philipp von Weitershausen
philipp at weitershausen.de
Mon Sep 18 18:50:54 EDT 2006
Chris Withers wrote:
> ...but which just gets the names of utilities available for a particular
> The reason I ask is that getUtilitiesFor returns tuples of name and
> utility. This seems wasteful, particular when the utilities need to be
> created from factories,
Utilities are never created when they're looked up. They're created when
registered. Singletons (instances) are registered with the utility
registry, never factories.
> and all I'm then doing with the list is
> generating a drop-down for people to select from...
getUtilitiesFor is all we have. If you want that drop-down, consider
using UtilityVocabulary from zope.app.component.vocabulary, e.g.:
interface = IFoo
nameOnly = True
Register that as a utility:
<utility component="...FooUtilityNames" name="Foo Utilities"/>
Then you can refer to it from a schema definition (Choice field).
More information about the Zope3-users