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 zope.app.component.vocabulary, e.g.:

 class FooUtilityNames(UtilityVocabulary):
     interface = IFoo
     nameOnly = True
     classProvides(IVocabularyFactory)

Register that as a utility:

  <utility component="...FooUtilityNames" name="Foo Utilities"/>

Then you can refer to it from a schema definition (Choice field).

Philipp

_______________________________________________
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users

Reply via email to