From ac1b519455256a4680c3221787a4ae1b77212248 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Benoi=CC=82t=20Pin?= Date: Mon, 21 Jul 2014 15:03:50 +0200 Subject: [PATCH 1/1] =?utf8?q?IHM=20pour=20=C3=A9dition=20des=20indexes=20?= =?utf8?q?d=C3=A9l=C3=A9gu=C3=A9s=20=C3=A0=20Solr.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- catalog.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/catalog.py b/catalog.py index 0a457f8..026bb04 100644 --- a/catalog.py +++ b/catalog.py @@ -5,7 +5,7 @@ from Products.CMFCore.interfaces import IIndexableObject from Products.CMFCore.CatalogTool import CatalogTool as BaseCatalogTool from Products.CMFCore.CatalogTool import IndexableObjectWrapper from Products.PageTemplates.PageTemplateFile import PageTemplateFile -from Products.CMFCore.permissions import ModifyPortalContent +from Products.CMFCore.permissions import ModifyPortalContent, ManagePortal from zope.component import queryMultiAdapter from Products.ZCatalog.Catalog import Catalog import transaction @@ -43,7 +43,8 @@ class CatalogTool(BaseCatalogTool) : manage_options = (BaseCatalogTool.manage_options[:5] + ({'label' : 'Solr', 'action' : 'manage_solr'},) + BaseCatalogTool.manage_options[5:]) - manage_solr = PageTemplateFile('www/manage_solr', globals()) + manage_solr = PageTemplateFile('www/manage_solr', globals(), __name__='manage_solr') + def __init__(self, idxs=[]) : @@ -52,6 +53,18 @@ class CatalogTool(BaseCatalogTool) : self.solr_url = 'http://localhost:8983/solr' self.delegatedIndexes = ('Title', 'Description', 'SearchableText') + security.declarePublic('getDelegatedIndexes') + def getDelegatedIndexes(self) : + """ read the method name """ + return self.delegatedIndexes + + security.declareProtected(ManagePortal, 'setDelegatedIndexes') + def setDelegatedIndexes(self, indexes, REQUEST=None) : + """setDelegatedIndexes documentation""" + self.delegatedIndexes = tuple([i.strip() for i in indexes if i.strip()]) + if REQUEST : + REQUEST.RESPONSE.redirect(self.absolute_url() + '/manage_solr?manage_tabs_message=Saved changes.') + def _getSolrConnection(self) : if not hasattr(self, _VOLATILE_SOLR_NAME) : con = SolrConnection(self.solr_url) -- 2.20.1