Commit adc7e054 authored by 's avatar

- improved index creation in ProductHelp

- removed special PluginIndexes handling in Product initialization code
parent 5564c2f2
......@@ -16,9 +16,18 @@ Features Added
* ZODB 3.9.0b2
Restructuring
+++++++++++++
- HelpSys now uses ZCTextIndex instead of the deprecated TextIndex. Please
update your Zope databases by deleting the Product registrations in the
Control Panel and restarting Zope.
Bugs Fixed
++++++++++
- HelpSys: ProductHelp no longer depends on PluginIndexes initialization.
- App.Product: ProductHelp was broken since Zope 2.12.0a1.
- ObjectManagerNameChooser now also works with BTreeFolder2.
......
......@@ -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._setObject('Help', ProductHelp('Help', id))
except:
pass
self.id = id
self.title = title
self._setObject('Help', ProductHelp('Help', id))
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