当前位置: 首页>>代码示例>>Python>>正文


Python ILinkIntegrityInfo.addDeletedItem方法代码示例

本文整理汇总了Python中plone.app.linkintegrity.interfaces.ILinkIntegrityInfo.addDeletedItem方法的典型用法代码示例。如果您正苦于以下问题:Python ILinkIntegrityInfo.addDeletedItem方法的具体用法?Python ILinkIntegrityInfo.addDeletedItem怎么用?Python ILinkIntegrityInfo.addDeletedItem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在plone.app.linkintegrity.interfaces.ILinkIntegrityInfo的用法示例。


在下文中一共展示了ILinkIntegrityInfo.addDeletedItem方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: delete

# 需要导入模块: from plone.app.linkintegrity.interfaces import ILinkIntegrityInfo [as 别名]
# 或者: from plone.app.linkintegrity.interfaces.ILinkIntegrityInfo import addDeletedItem [as 别名]
    def delete(self):
        uids = self.request['uids']
        ctool = getToolByName(self.context, 'portal_catalog')
        mtool = getToolByName(self.context, 'portal_membership')
        brains = ctool(UID=uids)
        fails = []
        success = 0
        integrity_info = ILinkIntegrityInfo(self.request)
        for b in brains:
            obj = b.getObject()
            integrity_info.addDeletedItem(obj)
            if not mtool.checkPermission('Delete objects', obj):
                fails.append(translate(_(u"Unauthorized: ${path}",
                                         mapping={'path': b.getPath()}),
                                       context=self.request))
            else:
                try:
                    parent = obj.getParentNode()
                    parent.manage_delObjects([obj.getId()])
                except LinkIntegrityNotificationException:
                    pass
                finally:
                    success += 1

        IStatusMessage(self.request).add(_("msg_objects_deleted",
                                           default="${num} object(s) deleted",
                                           mapping={'num': success}))
        if fails:
            IStatusMessage(self.request).add(
                      _("msg_objects_delete_failed",
                        default="${num} object(s) were not deleted : ${fails}",
                        mapping={'num': len(fails), 'fails': ", ".join(fails)}),
                      'error')
开发者ID:tdesvenain,项目名称:collective.contact.facetednav,代码行数:35,代码来源:delete.py

示例2: referencedObjectRemoved

# 需要导入模块: from plone.app.linkintegrity.interfaces import ILinkIntegrityInfo [as 别名]
# 或者: from plone.app.linkintegrity.interfaces.ILinkIntegrityInfo import addDeletedItem [as 别名]
def referencedObjectRemoved(obj, event):
    """ check if the removal was already confirmed or redirect to the form """
    # if the object the event was fired on doesn't have a `REQUEST` attribute
    # we can safely assume no direct user action was involved and therefore
    # never raise a link integrity exception...
    request = aq_get(obj, 'REQUEST', None)
    if not request:
        return
    info = ILinkIntegrityInfo(request)
    # first we check if link integrity checking was enabled
    if not info.integrityCheckingEnabled():
        return

    # since the event gets called for every subobject before it's
    # called for the item deleted directly via _delObject (event.object)
    # itself, but we do not want to present the user with a confirmation
    # form for every (referred) subobject, so we remember and skip them...
    info.addDeletedItem(obj)
    if obj is not event.object:
        return

    # if the number of expected events has been stored to help us prevent
    # multiple forms (i.e. in folder_delete), we wait for the next event
    # if we know there will be another...
    if info.moreEventsToExpect():
        return

    # at this point all subobjects have been removed already, so all
    # link integrity breaches caused by that have been collected as well;
    # if there aren't any (after things have been cleaned up),
    # we keep lurking in the shadows...
    if not info.getIntegrityBreaches():
        return

    # if the user has confirmed to remove the currently handled item in a
    # previous confirmation form we won't need it anymore this time around...
    if info.isConfirmedItem(obj):
        return

    # otherwise we raise an exception and pass the object that is supposed
    # to be removed as the exception value so we can use it as the context
    # for the view triggered by the exception;  this is needed since the
    # view is an adapter for the exception and a request, so it gets the
    # exception object as the context, which is not very useful...
    raise LinkIntegrityNotificationException(obj)
开发者ID:jsbueno,项目名称:plone.app.linkintegrity,代码行数:47,代码来源:handlers.py


注:本文中的plone.app.linkintegrity.interfaces.ILinkIntegrityInfo.addDeletedItem方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。