def newsitem_on_change(obj, evt): """ Handle newsitem changes """ try: z3c_index(obj) except Exception, err: logger.exception(err)
def game_on_add(obj, evt): """ Handle add """ try: addIntIdSubscriber(obj, evt) z3c_index(obj) except Exception, err: logger.exception(err)
def __call__(self, **kwargs): """ Evolve """ start = datetime.now() intids = queryUtility(IIntIds) timeline = queryUtility(ITimeline, name=u'news.timeline') logger.info('Indexing objects: %s', start.strftime('%Y-%m-%d %H:%M:%S')) tags = [self.context.__name__] for newsitem in self.context.values(): if not INewsItem.providedBy(newsitem): continue logger.info('Index object %s', absoluteURL(newsitem, self.request)) if not newsitem.tags: logger.info('Fix tags') newsitem.tags = tags if not newsitem.updated.tzinfo: args = newsitem.updated.timetuple()[:6] + (0, utc) logger.info('Fix updated datetime') newsitem.updated = datetime(*args) intids.register(newsitem) z3c_index(newsitem) timeline.index(newsitem) logger.info('Commit transaction') end = datetime.now() delta = end - start logger.info('Done: %s', end.strftime('%Y-%m-%d %H:%M:%S')) logger.info('Done in %s seconds', delta.seconds) return 'Done in %s seconds' % delta.seconds
def __call__(self, **kwargs): """ Evolve """ start = datetime.now() intids = queryUtility(IIntIds) logger.info('Indexing objects: %s', start.strftime('%Y-%m-%d %H:%M:%S')) for game in self.context.values(): if not IGame.providedBy(game): continue intids.register(game) z3c_index(game) end = datetime.now() delta = end - start logger.info('Done: %s', end.strftime('%Y-%m-%d %H:%M:%S')) logger.info('Done in %s seconds', delta.seconds) return 'Done in %s seconds' % delta.seconds
def game_on_change(obj, evt): """ Handle changes """ try: z3c_index(obj) except Exception, err: logger.exception(err)