From 1d01e224bcb37d7506679b524f90701254e8b051 Mon Sep 17 00:00:00 2001 From: Leandro Lucarella Date: Wed, 2 Jan 2008 00:33:14 -0200 Subject: [PATCH 1/1] Bugfix: use index/key to report ItemAlreadyExistsError. --- pymin/services/util.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/pymin/services/util.py b/pymin/services/util.py index acb9539..c3579c7 100644 --- a/pymin/services/util.py +++ b/pymin/services/util.py @@ -101,7 +101,7 @@ class ItemAlreadyExistsError(ItemError): def __init__(self, key): r"Initialize the object. See class documentation for more info." - self.message = u'Item already exists: "%s"' % key + self.message = u'Item already exists: %s' % key class ItemNotFoundError(ItemError): r""" @@ -850,7 +850,9 @@ class ContainerSubHandler(SubHandler): # do we have the same item? then raise an error if key in self._vattr(): log.debug(u'ContainerSubHandler.add: allready exists') - raise ItemAlreadyExistsError(item) + if not isinstance(self._attr(), dict): + key = self._attr().index(item) + raise ItemAlreadyExistsError(key) # do we have the same item, but logically deleted? then update flags if key in self._attr(): log.debug(u'ContainerSubHandler.add: was deleted, undeleting it') @@ -1049,7 +1051,9 @@ class ComposedSubHandler(SubHandler): # do we have the same item? then raise an error if key in self._vattr(cont): log.debug(u'ComposedSubHandler.add: allready exists') - raise ItemAlreadyExistsError(item) + if not isinstance(self._attr(), dict): + key = self._attr().index(item) + raise ItemAlreadyExistsError(key) # do we have the same item, but logically deleted? then update flags if key in self._attr(cont): log.debug(u'ComposedSubHandler.add: was deleted, undeleting it') -- 2.43.0