Guest User

Untitled

a guest
Jul 15th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1.  
  2. import transaction
  3.  
  4. class IndexProgressHandler( object ):
  5.  
  6. def __init__( self, batch_size=1000 ):
  7. self.batch_size = batch_size
  8. self.total_size = 0
  9. self.start_time = 0
  10.  
  11. def init( self, msg, num_objects ):
  12. self.total_size = num_objects
  13. self.start_time = time.time()
  14. log.info("Starting Catalog Reindex")
  15.  
  16. def report( self, i ):
  17. if i%self.batch_size: return
  18. log.info(" Records %s Completed %0.2f%%"%(i, (float(i)/self.total_size)*100) )
  19. transaction.commit()
  20.  
  21. def info( self, i ):
  22. log.info(" %s"%i)
  23.  
  24. def finish( self ):
  25. log.info("Indexing Complete in %s"%(ptime( time.time()-self.start_time )))
  26. transaction.commit()
  27.  
  28.  
  29. app.plone.portal_catalog.refreshCatalog( clear=1, pghandler=IndexProgressHandler() )
Add Comment
Please, Sign In to add comment