Am Montag, 5. Juni 2006 08:14 schrieb David Johnson:
> 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). 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.

getUtility does not require a name.

Example:

        from zope.app.zapi import getUtility
        from zope.app.homefolder.interfaces import IHomeFolderManager
        hfm = getUtility(IHomeFolderManager)

Regards,

Florian


>
> I come across this problem frequently and haven't figured out the best
> way to deal with it.
_______________________________________________
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users

Reply via email to