from BTrees.Length import Length def upgrade_ratings(folder): """ upgrades internal data structures of ratings object from version .1 -> .3 needs a fix to Ratings.py to work add a meta_type = 'Ratings' first!!! """ res = [] ratings = self.ZopeFind(folder, obj_metatypes=['Ratings'], search_sub=1) for p,r in ratings: data = r._data num_votes = len(data) r._num_votes = Length(num_votes) votesum = 0 for v in data.values(): votesum += v r._vote_sum = Length(votesum) res.append(p) header = "Fixed up the following ratings - (%s) "%(str(len(ratings))) body="

"%join(res, '
  • ') return header+body