Пример #1
0
 def __call__(self, *args, **kwargs):
     context = self.context
     request = self.request
     catalog = getToolByName(context, config.CATALOG_ID)
     storage = IDataStorage(context)
     # now we load the tabel view and rebuild all rows by using the ignore_cache parameter
     table_view = getMultiAdapter((context, request), name=u'view-table')
     table_view.rows(ignore_cache=True)
     for index, row in enumerate(storage):
         uuid = row.get('__uuid__')
         if not uuid:
             # this should not happen
             logger.warning(
                 "Row without an uuid! index %d, document at %s" %
                 (index, context.absolute_url_path()))
             continue
         catalog.reindex_rows(context, uuid, storage)
         if index and index % 100 == 0:
             logger.info("Refreshing catalog (%d)" % index)
             transaction.savepoint()
     logger.info("Refreshing catalog and caches: done")
     getToolByName(context, 'plone_utils').addPortalMessage(
         _('reindex_performed_message',
           u'$count rows has been updated',
           mapping={'count': index + 1}))
     request.response.redirect('%s/edit-table' % context.absolute_url())
Пример #2
0
 def catalog_label_row(self, context, row_data, idxs=[]):
     """Add new label data to catalog"""
     if not row_data.get('__uuid__'):
         # this should not happen
         logger.warning("Label without an uuid! data: %s" % row_data)
         return
     path = '%s/row-%s' % ('/'.join(context.getPhysicalPath()), row_data['__uuid__'])
     row_data['path'] = path
     self.catalog_object(CatalogDictLabelWrapper(row_data, context, path),
                         uid=path, idxs=idxs)
Пример #3
0
 def catalog_label_row(self, context, row_data, idxs=[]):
     """Add new label data to catalog"""
     if not row_data.get('__uuid__'):
         # this should not happen
         logger.warning("Label without an uuid! data: %s" % row_data)
         return
     path = '%s/row-%s' % ('/'.join(
         context.getPhysicalPath()), row_data['__uuid__'])
     row_data['path'] = path
     self.catalog_object(CatalogDictLabelWrapper(row_data, context, path),
                         uid=path,
                         idxs=idxs)
Пример #4
0
 def cache_time(self):
     """
     The cache_time attribute here is computed.
     Look at the column configuration, for a "cache:X" value, then
     column use X as cache
     """
     conf = self.configuration.get('vocabulary') or ''
     conf = conf.splitlines()
     cache_time = [l for l in conf if l.startswith('cache:')]
     if cache_time:
         try:
             return int(cache_time[0][6:])
         except ValueError:
             logger.warning('Invalid column cache value: %s' % cache_time[0][6:])
     return 0
Пример #5
0
 def cache_time(self):
     """
     The cache_time attribute here is computed.
     Look at the column configuration, for a "cache:X" value, then
     column use X as cache
     """
     conf = self.configuration.get('vocabulary') or ''
     conf = conf.splitlines()
     cache_time = [l for l in conf if l.startswith('cache:')]
     if cache_time:
         try:
             return int(cache_time[0][6:])
         except ValueError:
             logger.warning('Invalid column cache value: %s' %
                            cache_time[0][6:])
     return 0
Пример #6
0
 def __call__(self, *args, **kwargs):
     context = self.context
     request = self.request
     catalog = getToolByName(context, config.CATALOG_ID)
     storage = IDataStorage(context)
     # now we load the tabel view and rebuild all rows by using the ignore_cache parameter
     table_view = getMultiAdapter((context, request), name=u'view-table')
     table_view.rows(ignore_cache=True)
     for index, row in enumerate(storage):
         uuid = row.get('__uuid__')
         if not uuid:
             # this should not happen
             logger.warning("Row without an uuid! index %d, document at %s" % (index, context.absolute_url_path()))
             continue
         catalog.reindex_rows(context, uuid, storage)
         if index and index % 100 == 0:
             logger.info("Refreshing catalog (%d)" % index)
             transaction.savepoint()
     logger.info("Refreshing catalog and caches: done")
     getToolByName(context, 'plone_utils').addPortalMessage(_('reindex_performed_message',
                                                              u'$count rows has been updated',
                                                              mapping={'count': index+1}))
     request.response.redirect('%s/edit-table' % context.absolute_url())