Guest User

Untitled

a guest
Apr 25th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1.  
  2. def updatezbfilesizes(self):
  3. catalog = getToolByName(self, 'portal_catalog')
  4. zbfiles = catalog.searchResults(portal_type='ZBFile')
  5.  
  6. for f in zbfiles:
  7. o = f.getObject()
  8.  
  9. select_sql = "SELECT zbfile_id from zbfile WHERE media_id=%s AND file_nm='%s';" % (o.media_id, o.Title())
  10. LOG.info(select_sql)
  11. cursor.execute(select_sql)
  12.  
  13. row = cursor.fetchone()
  14. if row != None:
  15. update_sql = "UPDATE zbfile SET file_size=%s WHERE media_id=%s AND file_nm='%s';" % (f.get_size, o.media_id, o.Title())
  16. LOG.info(update_sql)
  17. cursor.execute(update_sql)
  18. else:
  19. LOG.info( "zbfile not found in database, media_id: %s\tfile_nm:%s" % (o.media_id, o.Title()) )
Add Comment
Please, Sign In to add comment