def customizeMemberCatalog(self, portal): from Products.ManagableIndex.FieldIndex import FieldIndex # Customize the member_catalog indexes catalog = getToolByName(portal, 'member_catalog') catalog.addIndex('firstname', 'FieldIndex') catalog.addIndex('approved_time', 'DateIndex') catalog.addColumn('approved_time') # Replace email index with Managable FieldIndex catalog.delIndex('email') index = FieldIndex('email') catalog._catalog.addIndex('email', index) index._updateProperty('TermType', 'string') # New Managable FieldIndex for surname so we can sort on it index = FieldIndex('surname') catalog._catalog.addIndex('surname', index) index._updateProperty('TermType', 'string') index._updateProperty('PrenormalizeTerm', 'python: value.lower()')
def hitCountUpgrade(self): """Upgrade the installed tool""" out = StringIO() out.write("Upgrading Risa Repository\n") content = getToolByName(self, 'content') fi = FieldIndex('sortTitle') content.catalog._catalog.addIndex('sortTitle', fi) fi._updateProperty('PrenormalizeTerm', 'python: value.lower()') fi._updateProperty('TermType', 'string') fi.sortTitle._updateProperty('Name', 'title') fi.sortTitle._updateProperty('Normalizer', 'python: here.stripArticles(value)') extra = Empty() extra.indexed_attrs = 'keywords' content.catalog.addIndex('keywordscase', 'KeywordIndex', extra) content.catalog.delColumn('icon') content.catalog.addColumn('getIcon') content.catalog.addColumn('url') content.catalog.addColumn('authors') content.catalog.addColumn('instructor') out.write("Upgraded catalog\n") types_tool = getToolByName(self, 'portal_types') # Plone1 version #types_tool.Repository._actions = ({'id':'view', 'name':'Browse', 'action':'browse_content', 'permissions':('View',),'visible':0},) types_tool.Repository._actions = [ ActionInformation('view', title='Browse', action='browse_content', permissions=(CMFCorePermissions.View), visible=0) ] out.write("Upgraded actions\n") right_slots = [ 'here/portlet_newest_content/macros/portlet', 'here/portlet_hits/macros/portlet' ] content._setProperty('right_slots', right_slots, type='lines') out.write("Upgraded portlets\n") content.catalog.refreshCatalog() out.write("Refreshed catalog\n") return out.getvalue()
def _create_catalog(self): """Creates the ZCatalog instance for versioned objects""" self.catalog = ZCatalog('catalog') lexicon = PLexicon('lexicon', '', Splitter(), CaseNormalizer(), StopWordAndSingleCharRemover()) self.catalog._setObject('lexicon', lexicon) ZCText_extras = Empty() ZCText_extras.doc_attr = 'abstract' ZCText_extras.index_type = 'Okapi BM25 Rank' ZCText_extras.lexicon_id = 'lexicon' self.catalog.addIndex('abstract', 'ZCTextIndex', ZCText_extras) ZCText_extras.doc_attr = 'Title' self.catalog.addIndex('Title', 'ZCTextIndex', ZCText_extras) ZCText_extras.doc_attr = 'institution' self.catalog.addIndex('institution', 'ZCTextIndex', ZCText_extras) ZCText_extras.doc_attr = 'keywords' self.catalog.addIndex('keywordstext', 'ZCTextIndex', ZCText_extras) self.catalog.addIndex('atomicInstitution', 'FieldIndex', {'indexed_attrs': 'institution'}) self.catalog.addIndex('authors', 'KeywordIndex') self.catalog.addIndex('parentAuthors', 'KeywordIndex') self.catalog.addIndex('maintainers', 'KeywordIndex') self.catalog.addIndex('language', 'KeywordIndex') self.catalog.addIndex('modified', 'DateIndex') self.catalog.addIndex('revised', 'DateIndex') self.catalog.addIndex('objectId', 'FieldIndex') self.catalog.addIndex('portal_type', 'FieldIndex') self.catalog.addIndex('containedModuleIds', 'KeywordIndex') self.catalog.addIndex('subject', 'KeywordIndex') extra = Empty() extra.indexed_attrs = 'keywords' self.catalog.addIndex('keywordscase', 'KeywordIndex', extra) ki = KeywordIndex('keywords') self.catalog._catalog.addIndex('keywords', ki) ki._updateProperty('PrenormalizeTerm', 'python: value.lower()') ki._updateProperty('TermType', 'string') ki.keywords._updateProperty('Normalizer', 'python: [k.lower() for k in value]') ki = KeywordIndex('baselanguage') self.catalog._catalog.addIndex('baselanguage', ki) ki._updateProperty( 'PrenormalizeTerm', "python: value[:(value.find('-') > 0 ) and value.find('-') or len(value)]" ) ki.baselanguage._updateProperty('Name', 'language') ki.baselanguage._updateProperty( 'Normalizer', "python: [value[:(value.find('-') > 0 ) and value.find('-') or len(value)]]" ) fi = FieldIndex('sortTitle') self.catalog._catalog.addIndex('sortTitle', fi) fi._updateProperty('PrenormalizeTerm', 'python: value.lower()') fi._updateProperty('TermType', 'string') fi.sortTitle._updateProperty('Name', 'Title') fi.sortTitle._updateProperty('Normalizer', 'python: here.stripArticles(value)') fi = FieldIndex('parent') self.catalog._catalog.addIndex('parent', fi) fi.parent._updateProperty('Name', 'getParent') fi.parent._updateProperty('Normalizer', 'python:value.objectId') ki = KeywordIndex('translators') self.catalog._catalog.addIndex('translators', ki) ki._delObject('translators') ee = ExpressionEvaluator() ee.id = 'translators' ki._setObject(ee.id, ee) ki.translators._updateProperty( 'Expression', "python: lambda o: o.roles['translators']") ki = KeywordIndex('editors') self.catalog._catalog.addIndex('editors', ki) ki._delObject('editors') ee = ExpressionEvaluator() ee.id = 'editors' ki._setObject(ee.id, ee) ki.editors._updateProperty('Expression', "python: lambda o: o.roles['editors']") self._set_metadata() self._p_changed = 1