本文整理汇总了Python中plone.app.linkintegrity.interfaces.ILinkIntegrityInfo.encodeConfirmedItems方法的典型用法代码示例。如果您正苦于以下问题:Python ILinkIntegrityInfo.encodeConfirmedItems方法的具体用法?Python ILinkIntegrityInfo.encodeConfirmedItems怎么用?Python ILinkIntegrityInfo.encodeConfirmedItems使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类plone.app.linkintegrity.interfaces.ILinkIntegrityInfo
的用法示例。
在下文中一共展示了ILinkIntegrityInfo.encodeConfirmedItems方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: clean_folder
# 需要导入模块: from plone.app.linkintegrity.interfaces import ILinkIntegrityInfo [as 别名]
# 或者: from plone.app.linkintegrity.interfaces.ILinkIntegrityInfo import encodeConfirmedItems [as 别名]
def clean_folder(self):
""" find folders that are empty and delete them
the loop run recursively until there is no more
folders to cancel
"""
catalog = self.portal_catalog
total = 0
transaction_threshold = 20
# var for infinite loop
empty_count = 42
# Start information log
info("START")
out = StringIO()
forced_delete = []
while empty_count != 0:
# Secure infinite loop
empty_count = 0
# Get all folders
folders = catalog.unrestrictedSearchResults({
'portal_type': ('ATFolder', 'Folder')
})
# Find empty folders and delete them
for folder in folders:
obj = folder._unrestrictedGetObject()
if len(obj.getFolderContents()) == 0:
empty_count += 1
total += 1
refs = obj.getBRefs(relationship='isReferencing')
try:
obj.aq_parent.manage_delObjects([folder.id])
except LinkIntegrityNotificationException:
li = ILinkIntegrityInfo(self.REQUEST)
self.REQUEST.environ['link_integrity_info'] = \
li.encodeConfirmedItems([obj])
forced_delete.append((obj.absolute_url(), refs))
info(obj.absolute_url())
# Commiting transaction
if empty_count % transaction_threshold == 0:
info("Commit: delete %s folders", transaction_threshold)
transaction.savepoint()
# End information log
info("COMPLETE, %s folders deleted", total)
print >> out, ("The following linkintegrity conflicts were encountered:")
print >> out, ("The conflicting objects have been deleted, "
"but the referencing pages should be updated.")
for failed, referencing in forced_delete:
print >> out, "This object failed reference integrity: ", failed
print >> out, "It was referenced by:"
for r in referencing:
print >> out, r.absolute_url()
print >> out, "Total objects deleted %s" % total
out.seek(0)
return out.read()
示例2: confirmedItems
# 需要导入模块: from plone.app.linkintegrity.interfaces import ILinkIntegrityInfo [as 别名]
# 或者: from plone.app.linkintegrity.interfaces.ILinkIntegrityInfo import encodeConfirmedItems [as 别名]
def confirmedItems(self):
info = ILinkIntegrityInfo(self.request)
targets = info.getIntegrityBreaches().keys()
return info.encodeConfirmedItems(additions=targets)