Hey, Tres Seaver wrote: [snip]
Any code today which wants a utility is calling 'getUtilty' (if it *knows* the utility must be registered) or 'queryUtility' (if it thinks it might not be). Less facetiously than my first challenge: please point to actual code in the wild which looks like::
try: foo = getUtilty(IFoo, name='bar') except ComponentLookupError: # do something
instead of::
foo = queryUtility(IFoo, name='bar') if foo is None: # do something
I will argue that any code doing the first, outside of maybe tests of the ZCA itself is plain broken.
I have code like that in the wild - I have no real reason why I didn't queryUtility, but I didn't think it mattered. Why is it plain broken? Isn't getUtility supported to raise ComponentLookupError if it cannot find the required utility? Regards, Martijn