Chris Withers wrote:
...but which just gets the names of utilities available for a particular interface.

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, e.g.:

 class FooUtilityNames(UtilityVocabulary):
     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).


Zope3-users mailing list

Reply via email to