source: main/waeup.ikoba/branches/uli-payments/src/waeup/ikoba/utils/browser.py @ 12688

Last change on this file since 12688 was 11954, checked in by Henrik Bettermann, 10 years ago

Remove tools.

rename institution company.

Remove some apis from docs.

  • Property svn:keywords set to Id
File size: 2.0 KB
Line 
1## $Id: browser.py 11954 2014-11-13 16:54:17Z henrik $
2##
3## Copyright (C) 2011 Uli Fouquet & Henrik Bettermann
4## This program is free software; you can redistribute it and/or modify
5## it under the terms of the GNU General Public License as published by
6## the Free Software Foundation; either version 2 of the License, or
7## (at your option) any later version.
8##
9## This program is distributed in the hope that it will be useful,
10## but WITHOUT ANY WARRANTY; without even the implied warranty of
11## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12## GNU General Public License for more details.
13##
14## You should have received a copy of the GNU General Public License
15## along with this program; if not, write to the Free Software
16## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17##
18"""UI components for utilities and helpers.
19"""
20
21import grok
22from zope.catalog.interfaces import ICatalog
23from zope.component import queryUtility, getUtility, createObject
24from waeup.ikoba.browser.layout import UtilityView
25from waeup.ikoba.interfaces import IObjectHistory
26
27from waeup.ikoba.interfaces import ICompany
28
29class ReindexPage(UtilityView, grok.View):
30    """ Reindex view.
31
32    Reindexes a catalog. For managers only.
33    """
34    grok.context(ICompany)
35    grok.name('reindex')
36    grok.require('waeup.managePortal')
37
38    def update(self,ctlg=None):
39        if ctlg is None:
40            self.flash('No catalog name provided.')
41            return
42        cat = queryUtility(ICatalog, name='%s_catalog' % ctlg)
43        if cat is None:
44            self.flash('%s_catalog does not exist' % ctlg)
45            return
46        self.context.logger.info(
47            'Catalog `%s_catalog` re-indexing started.' % ctlg)
48        cat.updateIndexes()
49        no_of_entries = cat.values()[0].documentCount()
50        self.flash('%d %s re-indexed.' % (no_of_entries,ctlg))
51        self.context.logger.info(
52            'Re-indexing of %d objects finished.' % no_of_entries)
53        return
54
55    def render(self):
56        self.redirect(self.url(self.context, '@@index'))
57        return
Note: See TracBrowser for help on using the repository browser.