def populate_with_object(self, obj): # check permissions super(ImageTile, self).populate_with_object(obj) data = {} obj = aq_inner(obj) try: scales = queryMultiAdapter((obj, self.request), name="images") data['image'] = NamedImageFile(str(scales.scale('image').data)) except AttributeError: pass data_mgr = ITileDataManager(self) data_mgr.set(data) tile_storage = AnnotationStorage(self) obj_storage = BaseAnnotationStorage(obj) for k, v in obj_storage.items(): tile_storage.storage[k] = v tile_storage.storage[k]['modified'] = '%f' % time.time() scale_data = obj_storage.storage[k]['data'].open().read() tile_storage.storage[k]['data'] = NamedImageFile(str(scale_data))
obj = brain.getObject() except: continue savepoint = transaction.savepoint() ann = AnnotationStorage(obj) try: ann.storage except TypeError: # This happens when the context cannot be annotated, for # example for a plone.app.discussion comment. continue # We want to remove all scales that are X days older than the # last modification date of the object. final_date = obj.modified() - DAYS changed = False for key, value in ann.items(): if value['modified'] < final_date.millis(): # This may easily give an error, as it tries to remove # two keys: del ann[key] del ann.storage[key] purged += 1 changed = True if not changed: # This avoids adding an empty annotation for items that # will never store scales. savepoint.rollback() else: count += 1 if count % LIMIT == 0: note = ('Purged %d outdated image scales for %d items in ' 'Plone Site %s.' % (purged, count, site.id))
obj = brain.getObject() except: continue savepoint = transaction.savepoint() ann = AnnotationStorage(obj) try: ann.storage except TypeError: # This happens when the context cannot be annotated, for # example for a plone.app.discussion comment. continue # We want to remove all scales that are X days older than the # last modification date of the object. final_date = obj.modified() - DAYS changed = False for key, value in ann.items(): if value['modified'] < final_date.millis(): # This may easily give an error, as it tries to remove # two keys: del ann[key] del ann.storage[key] purged += 1 changed = True if not changed: # This avoids adding an empty annotation for items that # will never store scales. savepoint.rollback() else: count += 1 if count % LIMIT == 0: note = ('Purged %d outdated image scales for %d items in ' 'Plone Site %s.' % (purged, count, site.id))