From brian@hkpharma.com:
I've made some changes to one
file in particular to make globbing exist after re-indexing the Catalog from
the management screen.
So far we have:
1. Globbing
remains after reindexing the catalog in Documents Folder and
reindexing works as intended.
Caveats: I don't know how to
replace/fix a Library that is in production--that's one of the reasons why I
had to fix it before I can start coding an application--so test before using but I
haven't found errors in my environment. First a little history: Essentially
the file I worked on is the "DocumentStore.py". The last method: "def
manage_reinitCatalog(self.....):" is where the reindexing takes place.
First there is a call to self.Catalog.clear() which removes all the entries in
the Catalog--actually that call clears the Indexes which clears the
Vocabulary. Then there is a loop to index all the documents (
doc.index_object() ) However, after the call to clear, the DocumentStore
then doesn't have a clue that it has a Vocabulary associated with it;
hence, the content for TextIndexes don't get put in there and also no
globbing is available. TopicIndex doesn't forget about the Vocabulary
since a "clear" was never called on it.
So how to fix?? : Basically I
took the portion of the code that creates the Catalog in the first place and
made a method, called remake_Catalog, that can be called from the
manage_reinitCatalog method. Of course, I call clear on the old-Catalog
(which clears the Vocabulary) then point the old-Catalog to "None" (just in
case) before I create a new Catalog. All in all, the old Catalog really gets
wiped out forcibly and a new one is put in and then all the Documents gets
indexed into the new one. A subtle difference only. Here's the code
part:
def remake_Catalog(self):
# Probably should call the
self.Catalog.clear() here instead of in # manage_reinitCatalog but
what if you didn't want to clear the # Vocabulary.
self.Catalog =
CatalogPlus(vocabulary=self.vocab_id)
self.lexicon =
self.Catalog.getLexicon()
for name in
self._defaultCatalogColumns:
self.Catalog.addColumn(name)
for name, index_class in
self._defaultCatalogIndexes:
if index_class is TextIndex:
self.Catalog.addIndex(name, index_class(name,
lexicon=self.lexicon))
else:
self.Catalog.addIndex(name,
index_class(name))
What's not fixed:
1. It seems that
when a document gets deleted its indexed info is not removed. I might
have to call self.Catalog.uncatalog_object() on the document before
calling manage_delObject() on it. But since the object is in a catalog I
don't know what uncatalog would do to an object's id, etc,--keep in mind
that I still need at least the object's id to remove it from Zope--and I don't want
to have to add a 'mark for delete' property on documents.
DocumentStore.py