Commit 5fa82d8e authored by Andreas Jung's avatar Andreas Jung

Made aquisition of vocabularies for TextIndexes working.

parent bd2ea537
...@@ -87,7 +87,7 @@ ...@@ -87,7 +87,7 @@
""" """
__version__ = '$Revision: 1.11 $'[11:-2] __version__ = '$Revision: 1.12 $'[11:-2]
import string, re import string, re
...@@ -185,8 +185,14 @@ class TextIndex(PluggableIndex.PluggableIndex, Persistent, ...@@ -185,8 +185,14 @@ class TextIndex(PluggableIndex.PluggableIndex, Persistent,
self.clear() self.clear()
if extra: self.vocabulary_id = extra.vocabulary if extra:
else: self.vocabulary_id = "Vocabulary" self.vocabulary_id = extra.vocabulary
self.catalog = extra.catalog
else:
self.vocabulary_id = "Vocabulary"
self.catalog = None
self._lexicon = None self._lexicon = None
...@@ -198,13 +204,16 @@ class TextIndex(PluggableIndex.PluggableIndex, Persistent, ...@@ -198,13 +204,16 @@ class TextIndex(PluggableIndex.PluggableIndex, Persistent,
self.vocabulary_id = '__userdefined__' self.vocabulary_id = '__userdefined__'
def getLexicon(self, vocab_id=None): def getLexicon(self, vocab_id=None):
"""Return the Lexicon in use. Removed lots of stinking code""" """Return the Lexicon in use. Removed lots of stinking code"""
if self._lexicon is None: if self._lexicon is None:
## if no lexicon is provided, create a default one ## if no lexicon is provided, create a default one
try: try:
self._lexicon = self.aq_parent.getattr(self.vocabulary_id).getLexicon() self._lexicon = getattr(self.catalog,self.vocabulary_id).getLexicon()
except: except:
self._lexicon = Lexicon() self._lexicon = Lexicon()
self.vocabulary_id = '__intern__' self.vocabulary_id = '__intern__'
...@@ -348,6 +357,7 @@ class TextIndex(PluggableIndex.PluggableIndex, Persistent, ...@@ -348,6 +357,7 @@ class TextIndex(PluggableIndex.PluggableIndex, Persistent,
return 0 return 0
lexicon = self.getLexicon() lexicon = self.getLexicon()
splitter = lexicon.Splitter splitter = lexicon.Splitter
wordScores = OIBTree() wordScores = OIBTree()
......
...@@ -830,6 +830,7 @@ class ZCatalog(Folder, Persistent, Implicit): ...@@ -830,6 +830,7 @@ class ZCatalog(Folder, Persistent, Implicit):
# an "extra" record. # an "extra" record.
if 'extra' in base.__init__.func_code.co_varnames: if 'extra' in base.__init__.func_code.co_varnames:
extra.catalog = self
index = apply(base,(name,), {"extra":extra}) index = apply(base,(name,), {"extra":extra})
else: else:
index = base(name,self) index = base(name,self)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment