[Zope3-Users] Utilities

David Johnson djohnson at jsatech.com
Mon Jun 5 10:44:33 EDT 2006


Thanks! That's it exactly!  I was misunderstanding the concept of a
utility with the name ''.  



On Mon, 2006-06-05 at 17:34 +0300, Albertas Agejevas wrote:
> On Mon, Jun 05, 2006 at 09:22:13AM -0500, David Johnson wrote:
> > 
> > > getUtility does not require a name.
> > 
> > I've tried getUtility() without a name it never returns an interface and
> > returns component lookup error.
> 
> Because you haven't registered a single utility with the given
> interface and name ''!
> 
> > I've tried in many different instances,
> > and I've ended up reverting as a work around to
> > getAllRegisteredUtilitiesFor(), which works just fine.
> 
> getAllRegisteredUtilitiesFor returns even the utilities that are
> "overriden" by closer utilities with the same name and interface.
> 
> > Once I add the name it works great. What am I missing? Is there
> > some other requirement?  My code looks the same as what you've
> > listed.
> 
> I suspect you expect getUtility(ISomething) to return a utility with
> *any* name of that interface (that's what
> get(AllRegistered)UtilitiesFor() does).  But getUtility(ISomething)
> returns just the utilities with the name you've passed ('' by default).
> 
> I think I already explained that in my previous email.
> 
> Albertas
> 



More information about the Zope3-users mailing list