Keyword Indexes causing Keyerrors
I'm getting tons and tons of keyerrors when making changes to a catalogaware object's keyword index and then reindex_object() it. Alternatively, the Catalog doesn't get updated at all. Is there any way to prevent this from happening, other than upgrading to 2.3? -- Email: itamar(at)shtull-trauring.org Web: http://itamarst.org
On 12/20/00 11:33 AM, "Itamar Shtull-Trauring" <itamar@maxnm.com> wrote:
I'm getting tons and tons of keyerrors when making changes to a catalogaware object's keyword index and then reindex_object() it. Alternatively, the Catalog doesn't get updated at all. Is there any way to prevent this from happening, other than upgrading to 2.3?
Are you getting KeyErrors or are you getting log messages complaining about keyts not existing? Chris -- | Christopher Petrilli Digital Creations | petrilli@digicool.com Where Zope comes from
Christopher Petrilli wrote:
Are you getting KeyErrors or are you getting log messages complaining about keyts not existing?
KeyErrors - the logging says: 2000-12-20T16:33:00 ERROR(200) UnKeywordIndex unindex_object could not remove 3 from set -- Email: itamar(at)shtull-trauring.org Web: http://itamarst.org
On 12/20/00 11:52 AM, "Itamar Shtull-Trauring" <itamar@maxnm.com> wrote:
KeyErrors - the logging says: 2000-12-20T16:33:00 ERROR(200) UnKeywordIndex unindex_object could not remove 3 from set
This is not the "KeyError" in the sense that it's not propogated up to the top level, but it is a lookup error lower down. I will look into this, but it seems to continue to work correctly, even with the log messages (these are all due to trying to make sure things get unindexed correctly before reindexing). Are you getting incorrect data after reindexing the object? Chris -- | Christopher Petrilli Digital Creations | petrilli@digicool.com Where Zope comes from
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 categories.remove(self.uid) ob.manage_changeProperties(categories=categories) ob.reindex_object() I solved the problem by switching the problem line to say "categories = ob.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 UnKeywordIndex.py (2.2.4 version) from: unindex[i] = kws to: unindex[i] = kws[:] Although use of deepcopy may be a better idea? -- Email: itamar(at)shtull-trauring.org Web: http://itamarst.org
participants (2)
-
Christopher Petrilli -
Itamar Shtull-Trauring