[Zope3-Users] Creating utilities overhead

Stephan Richter srichter at cosmos.phy.tufts.edu
Thu May 5 15:48:50 EDT 2005


On Tuesday 03 May 2005 09:18, Andreas Jung wrote:
> I have an utility registered as
>
> <utility
>   provides="textindexng.interfaces.ILexicon"
>   factory="textindexng.lexicon.LexiconFactory"
>   name="txng.lexicons.default"
>
> />
>
> trying to create a new Lexicon instance through
>
>  lexicon zapi.createObject(None, 'txng.lexicons.default')
>
> does not work (Zope 2.8, Five) because the factory does not seem
> to be registered for IFactory.

Right. Because the directive immediately instantiates the utility.

> Adding
>
> <utility
>   provides="zope.component.interfaces.IFactory"
>   component="textindexng.lexicon.LexionFactory"
>   name="txng.lexicons.default"
> />
>
> resolves the issue. But why is the explicit declaration of the factory
> necessary? IMO the first declaration implies the second one. So this
> looks like configuration overhead to me...thoughts?

Well, this is totally different. Here you register a factory called 
"txng.lexicons.default", not a utility! So getUtility() will not work.

Regards,
Stephan
-- 
Stephan Richter
CBU Physics & Chemistry (B.S.) / Tufts Physics (Ph.D. student)
Web2k - Web Software Design, Development and Training


More information about the Zope3-users mailing list