當前位置: 首頁>>代碼示例>>Python>>正文


Python ILinkIntegrityInfo.encodeConfirmedItems方法代碼示例

本文整理匯總了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()
開發者ID:eea,項目名稱:Products.EEAPloneAdmin,代碼行數:68,代碼來源:clean_empty_folders.py

示例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)
開發者ID:CGTIC,項目名稱:Plone_SP,代碼行數:6,代碼來源:confirmation.py


注:本文中的plone.app.linkintegrity.interfaces.ILinkIntegrityInfo.encodeConfirmedItems方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。