本文整理匯總了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)