当前位置: 首页>>代码示例>>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;未经允许,请勿转载。