本文整理汇总了Python中plone.scale.storage.AnnotationStorage.items方法的典型用法代码示例。如果您正苦于以下问题:Python AnnotationStorage.items方法的具体用法?Python AnnotationStorage.items怎么用?Python AnnotationStorage.items使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类plone.scale.storage.AnnotationStorage
的用法示例。
在下文中一共展示了AnnotationStorage.items方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: populate_with_object
# 需要导入模块: from plone.scale.storage import AnnotationStorage [as 别名]
# 或者: from plone.scale.storage.AnnotationStorage import items [as 别名]
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))
示例2: AnnotationStorage
# 需要导入模块: from plone.scale.storage import AnnotationStorage [as 别名]
# 或者: from plone.scale.storage.AnnotationStorage import items [as 别名]
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))