Here's what was causing my KeyErrors, and how I solved it, and why I think
KeywordIndexes broke. I have a keyword index on the "categories" property of
my CatalogAware object. "categories" is a list.

    def manage_removeItems(self, ids=[]):
        """ Remove listed items from this category """
        for id in ids:
            ob = getattr(self.Items, id)
            categories = ob.categories # <-- this is the problem

I solved the problem by switching the problem line to say "categories =

What does this mean? I was mutating the same list that was attached to the
object. Doing this caused the Keyword Index to break. I assume the reason
then is that the index somewhere stored a reference to the "categories"
property, not a copy. This means that when I mutated ob.categories, I was
also mutating the contents of the index, causing it to get screwed up. The
solution would be that keyword indexes store a *copy* of the property they
are indexing, not a reference to it.

If I'm not mistaken, that means changing line 42 in (2.2.4
version) from:

        unindex[i] = kws

        unindex[i] = kws[:]

Although use of deepcopy may be a better idea?

Email: itamar(at)

Zope-Dev maillist  -  [EMAIL PROTECTED]
**  No cross posts or HTML encoding!  **
(Related lists - )

Reply via email to