[Checkins] SVN: zope.component/trunk/ - Fixed a problem, where ``queryNextUtility`` could fail if the context could
Stephan Richter
srichter at gmail.com
Fri Jul 24 04:56:57 EDT 2009
Log message for revision 102214:
- Fixed a problem, where ``queryNextUtility`` could fail if the context could
not be adapted to a ``IComponentLookup``.
Changed:
U zope.component/trunk/CHANGES.txt
U zope.component/trunk/setup.py
U zope.component/trunk/src/zope/component/_api.py
U zope.component/trunk/src/zope/component/tests.py
-=-
Modified: zope.component/trunk/CHANGES.txt
===================================================================
--- zope.component/trunk/CHANGES.txt 2009-07-24 08:37:31 UTC (rev 102213)
+++ zope.component/trunk/CHANGES.txt 2009-07-24 08:56:56 UTC (rev 102214)
@@ -1,9 +1,12 @@
CHANGES
*******
-3.7.1 (unreleased)
+3.7.1 (2009-07-24)
==================
+- Fixed a problem, where ``queryNextUtility`` could fail if the context could
+ not be adapted to a ``IComponentLookup``.
+
- Fixed 2 related bugs:
When a utility is registered and there was previously a utility
Modified: zope.component/trunk/setup.py
===================================================================
--- zope.component/trunk/setup.py 2009-07-24 08:37:31 UTC (rev 102213)
+++ zope.component/trunk/setup.py 2009-07-24 08:56:56 UTC (rev 102214)
@@ -25,7 +25,7 @@
setup(
name='zope.component',
- version = '3.7.1dev',
+ version = '3.7.1',
url='http://pypi.python.org/pypi/zope.component',
license='ZPL 2.1',
description='Zope Component Architecture',
Modified: zope.component/trunk/src/zope/component/_api.py
===================================================================
--- zope.component/trunk/src/zope/component/_api.py 2009-07-24 08:37:31 UTC (rev 102213)
+++ zope.component/trunk/src/zope/component/_api.py 2009-07-24 08:56:56 UTC (rev 102214)
@@ -190,7 +190,10 @@
specified name. If no utility was found, return the specified `default`
value.
"""
- sm = getSiteManager(context)
+ try:
+ sm = getSiteManager(context)
+ except ComponentLookupError:
+ return default
bases = sm.__bases__
for base in bases:
util = base.queryUtility(interface, name, _marker)
Modified: zope.component/trunk/src/zope/component/tests.py
===================================================================
--- zope.component/trunk/src/zope/component/tests.py 2009-07-24 08:37:31 UTC (rev 102213)
+++ zope.component/trunk/src/zope/component/tests.py 2009-07-24 08:56:56 UTC (rev 102214)
@@ -1047,6 +1047,12 @@
MyUtility('my_custom_util')
>>> queryNextUtility(sm1, IMyUtility, 'myutil')
MyUtility('global')
+
+ Note, if the context cannot be converted to a site manager, the default is
+ retruned:
+
+ >>> queryNextUtility(object(), IMyUtility, 'myutil', 'default')
+ 'default'
"""
def dont_leak_utility_registrations_in__subscribers():
More information about the Checkins
mailing list