Commit 0aa3f2ea authored by 's avatar

- improved index creation in ProductHelp

- removed special PluginIndexes handling in Product initialization code
parent 52797a27
......@@ -101,16 +101,9 @@ class Product(Folder, PermissionManager):
def __init__(self, id, title):
from HelpSys.HelpSys import ProductHelp
self.id=id
self.title=title
# Workaround for unknown problem with help system and PluginIndexes product
# NEEDS to be fixed for 2.4 ! (ajung)
try:
self.id = id
self.title = title
self._setObject('Help', ProductHelp('Help', id))
except:
pass
security.declarePublic('Destination')
def Destination(self):
......
......@@ -23,8 +23,16 @@ from App.special_dtml import HTML
from OFS.ObjectManager import ObjectManager
from OFS.SimpleItem import Item
from Persistence import Persistent
from Products.PluginIndexes.KeywordIndex.KeywordIndex import KeywordIndex
from Products.ZCatalog.ZCatalog import ZCatalog
from Products.ZCatalog.Lazy import LazyCat
from Products.ZCTextIndex.OkapiIndex import OkapiIndex
from Products.ZCTextIndex.Lexicon import CaseNormalizer
from Products.ZCTextIndex.HTMLSplitter import HTMLWordSplitter
from Products.ZCTextIndex.Lexicon import StopWordRemover
from Products.ZCTextIndex.ZCTextIndex import PLexicon
from Products.ZCTextIndex.ZCTextIndex import ZCTextIndex
class HelpSys(Implicit, ObjectManager, Item, Persistent):
"""
......@@ -221,17 +229,19 @@ class ProductHelp(Implicit, ObjectManager, Item, Persistent):
)
def __init__(self, id='Help', title=''):
self.id=id
self.title=title
c=self.catalog=ZCatalog('catalog')
# clear catalog
for index in c.indexes():
c.delIndex(index)
for col in c.schema():
c.delColumn(col)
c.addIndex('SearchableText', 'TextIndex')
c.addIndex('categories', 'KeywordIndex')
c.addIndex('permissions', 'KeywordIndex')
self.id = id
self.title = title
c = self.catalog = ZCatalog('catalog')
l = PLexicon('lexicon', '', HTMLWordSplitter(), CaseNormalizer(),
StopWordRemover())
c._setObject('lexicon', l)
i = ZCTextIndex('SearchableText', caller=c, index_factory=OkapiIndex,
lexicon_id=l.id)
# not using c.addIndex because it depends on Product initialization
c._catalog.addIndex('SearchableText', i)
c._catalog.addIndex('categories', KeywordIndex('categories'))
c._catalog.addIndex('permissions', KeywordIndex('permissions'))
c.addColumn('categories')
c.addColumn('permissions')
c.addColumn('title_or_id')
......
......@@ -547,12 +547,10 @@ def get_products():
if ( os.path.exists(os.path.join(fullpath, '__init__.py')) or
os.path.exists(os.path.join(fullpath, '__init__.pyo')) or
os.path.exists(os.path.join(fullpath, '__init__.pyc')) ):
# import PluginIndexes 1st (why?)
priority = (name != 'PluginIndexes')
# i is used as sort ordering in case a conflict exists
# between Product names. Products will be found as
# per the ordering of Products.__path__
products.append((priority, name, i, product_dir))
products.append((0, name, i, product_dir))
i = i + 1
products.sort()
return products
......
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