On Mon, Jun 05, 2006 at 01:14:58AM -0500, David Johnson wrote:
> What is the best to find the nearest utility without using a name? 
> zapi.getUtility() seems to require a name (though the documentation
> implies otherwise).

The default name is ''.  If you're asking for z.c.getUtility(ISomething),
you'll get that -- the nearest utility with a given interface and name
''.  These used to be called services three years ago.

> zapi.getAllRegisiteredUtilitiesFor() works but it
> seems to me if you have lots of utilities in other contexts, it would
> query those as well, and thereby be slow in a large application.
> I come across this problem frequently and haven't figured out the best
> way to deal with it.

If you want to get all utilities with a given interface, use
z.c.getUtilitiesFor(ISomething).  You'll get the nearest utility with
each given name.


Attachment: signature.asc
Description: Digital signature

Zope3-users mailing list

Reply via email to