Guest User

Untitled

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