## $Id: browser.py 11954 2014-11-13 16:54:17Z henrik $ ## ## Copyright (C) 2011 Uli Fouquet & Henrik Bettermann ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 2 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program; if not, write to the Free Software ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ## """UI components for utilities and helpers. """ import grok from zope.catalog.interfaces import ICatalog from zope.component import queryUtility, getUtility, createObject from waeup.ikoba.browser.layout import UtilityView from waeup.ikoba.interfaces import IObjectHistory from waeup.ikoba.interfaces import ICompany class ReindexPage(UtilityView, grok.View): """ Reindex view. Reindexes a catalog. For managers only. """ grok.context(ICompany) grok.name('reindex') grok.require('waeup.managePortal') def update(self,ctlg=None): if ctlg is None: self.flash('No catalog name provided.') return cat = queryUtility(ICatalog, name='%s_catalog' % ctlg) if cat is None: self.flash('%s_catalog does not exist' % ctlg) return self.context.logger.info( 'Catalog `%s_catalog` re-indexing started.' % ctlg) cat.updateIndexes() no_of_entries = cat.values()[0].documentCount() self.flash('%d %s re-indexed.' % (no_of_entries,ctlg)) self.context.logger.info( 'Re-indexing of %d objects finished.' % no_of_entries) return def render(self): self.redirect(self.url(self.context, '@@index')) return