[ZODB-Dev] odd KeyError in OOSets
Nicholas Henke
henken at seas.upenn.edu
Fri Apr 18 21:08:30 EDT 2003
Hey guys -- I am running zodb-3.1.1 and python2.2.2 with the latest cvs
version of IndexedCatalog. I am playing with using OOSets instead of
Python Lists as the data store for the index data, and have hit a
strange error. I am getting a KeyError, but if I look at all of the
data, it would appear that it is in the OOSet. Below is some data
printouts -- the object I am trying to remove, with the OOSet, as well
as the id() of each of them.
The relevant code is:
def index_item(self, value, object):
index = self._index
if not index.has_key(value):
index[value] = OOSet()
elif self._unique:
raise UniqueError, \
"value %s is already in the index %s" % (`value`, `self`)
idx = index[value]
# Check for duplicates
if not object in idx:
index[value] = idx
idx.insert(object)
else:
# we already had that in the db :(
pass
def unindex_item(self, value, object):
index = self._index
current = index[value]
index[value] = current
try:
current.remove(object)
except KeyError:
print "KEYERROR, looking for %s, while having %s"
%(object,current)
print "Object id:", id(object)
for o in current:
print "Obj:", o, "id:", id(o)
raise
Thoughts?
KEYERROR, looking for <ClubmaskObject node2 at 0x83381c8>, while having
OOSet([<ClubmaskObject node0 at 0x8333e48>, <ClubmaskObject node3 at
0x8335c60>, <ClubmaskObject node6 at
0x8336848>, <ClubmaskObject node7 at 0x83376c8>, <ClubmaskObject node2
at 0x83381c8>, <ClubmaskObject node1 at 0x8336c80>, <ClubmaskObject
node4 at 0x8339740>])
Object id: 137593288
Obj: <ClubmaskObject node0 at 0x8333e48> id: 137576008
Obj: <ClubmaskObject node3 at 0x8335c60> id: 137583712
Obj: <ClubmaskObject node6 at 0x8336848> id: 137586760
Obj: <ClubmaskObject node7 at 0x83376c8> id: 137590472
Obj: <ClubmaskObject node2 at 0x83381c8> id: 137593288
Obj: <ClubmaskObject node1 at 0x8336c80> id: 137587840
Obj: <ClubmaskObject node4 at 0x8339740> id: 137598784
Exception in thread ResourceManager:
Traceback (most recent call last):
File "/var/tmp/python2.2.2-2.2.2-root/usr/lib/python2.2/threading.py",
line 408, in __bootstrap
self.run()
File "resource_manager.py", line 48, in run
self.go()
File "resource_manager.py", line 85, in go
self._setupManagers()
File
"/usr/lib/python2.2/site-packages/clubmask/resource_manager/ResourceManager.py", line 50, in _setupManagers
self._registerResourceManager(rm)
File
"/usr/lib/python2.2/site-packages/clubmask/resource_manager/ResourceManager.py", line 56, in _registerResourceManager
manager_instance = manager(db)
File
"/usr/lib/python2.2/site-packages/clubmask/resource_manager/Machine.py",
line 37, in __init__
self.supermon.getStaticData()
File
"/usr/lib/python2.2/site-packages/clubmask/supermon/SupermonInterface.py", line 365, in getStaticData
self.findNodes()
File
"/usr/lib/python2.2/site-packages/clubmask/supermon/SupermonInterface.py", line 182, in findNodes
self.newNode(nodeid)
File
"/usr/lib/python2.2/site-packages/clubmask/supermon/SupermonInterface.py", line 203, in newNode
obj.roletype = "compute"
File
"/usr/lib/python2.2/site-packages/clubmask/database/ClubmaskClass.py",
line 152, in __setattr__
IndexedObject.__setattr__(self, name, value)
File "/usr/lib/python2.2/site-packages/IndexedCatalog/Object.py", line
68, in __setattr__
self._ic_update(catalog, name, value, oldvalue)
File "/usr/lib/python2.2/site-packages/IndexedCatalog/Object.py", line
129, in _ic_update
catalog.index.update_one(name, self, newvalue, oldvalue)
File "/usr/lib/python2.2/site-packages/IndexedCatalog/Indexes.py",
line 145, in update_one
self.unindex_attribute(name, oldvalue, object)
File "/usr/lib/python2.2/site-packages/IndexedCatalog/Indexes.py",
line 122, in unindex_attribute
self._indexes[name].unindex_item(value, data)
File "/usr/lib/python2.2/site-packages/IndexedCatalog/Indexes.py",
line 309, in unindex_item
current.remove(object)
KeyError: <ClubmaskObject node2 at 0x83381c8>
Nic
--
Nicholas Henke
Penguin Herder & Linux Cluster System Programmer
Liniac Project - Univ. of Pennsylvania
More information about the ZODB-Dev
mailing list