[Zope3-checkins] CVS: Zope3/src/zope/app/services - configuration.py:1.24
Guido van Rossum
guido@python.org
Mon, 28 Apr 2003 15:31:33 -0400
Update of /cvs-repository/Zope3/src/zope/app/services
In directory cvs.zope.org:/tmp/cvs-serv13847
Modified Files:
configuration.py
Log Message:
In removeUsage(), don't do unnecessary work if the location is not
actually there; don't create a USE_CONFIG_KEY entry with () as value;
delete an empty USE_CONFIG_KEY key.
=== Zope3/src/zope/app/services/configuration.py 1.23 => 1.24 ===
--- Zope3/src/zope/app/services/configuration.py:1.23 Mon Apr 28 13:08:39 2003
+++ Zope3/src/zope/app/services/configuration.py Mon Apr 28 15:31:32 2003
@@ -498,9 +498,14 @@
def removeUsage(self, location):
annotations = getAdapter(self.context, IAnnotations)
- locs = [loc for loc in annotations.get(USE_CONFIG_KEY, ())
- if loc != location]
- annotations[USE_CONFIG_KEY] = tuple(locs)
+ locations = annotations.get(USE_CONFIG_KEY, ())
+ if locations:
+ locs = tuple([loc for loc in locations if loc != location])
+ if locs != locations:
+ if locs:
+ annotations[USE_CONFIG_KEY] = locs
+ else:
+ del annotations[USE_CONFIG_KEY]
def usages(self):
annotations = getAdapter(self.context, IAnnotations)