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


Python ILinkIntegrityInfo.isConfirmedItem方法代碼示例

本文整理匯總了Python中plone.app.linkintegrity.interfaces.ILinkIntegrityInfo.isConfirmedItem方法的典型用法代碼示例。如果您正苦於以下問題:Python ILinkIntegrityInfo.isConfirmedItem方法的具體用法?Python ILinkIntegrityInfo.isConfirmedItem怎麽用?Python ILinkIntegrityInfo.isConfirmedItem使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在plone.app.linkintegrity.interfaces.ILinkIntegrityInfo的用法示例。


在下文中一共展示了ILinkIntegrityInfo.isConfirmedItem方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: is_relevant

# 需要導入模塊: from plone.app.linkintegrity.interfaces import ILinkIntegrityInfo [as 別名]
# 或者: from plone.app.linkintegrity.interfaces.ILinkIntegrityInfo import isConfirmedItem [as 別名]
    def is_relevant(self):
        request = self.obj.REQUEST
        if getattr(request, '_activity_reported', False):
            return False
        else:
            setattr(request, '_activity_reported', True)

        info = ILinkIntegrityInfo(request)
        if not info.integrityCheckingEnabled():
            return True

        elif info.isConfirmedItem(self.obj):
            return True

        if request.URL.endswith('/sl_delete_object'):
            return True

        if request.has_key('form.submitted') and \
                request.URL.endswith('/delete_confirmation'):
            return True

        if request.URL.endswith('/folder_delete'):
            return True

        if request.has_key('form.button.Cancel'):
            return True

        return False
開發者ID:4teamwork,項目名稱:ftw.activitystation,代碼行數:30,代碼來源:activities.py

示例2: isLinked

# 需要導入模塊: from plone.app.linkintegrity.interfaces import ILinkIntegrityInfo [as 別名]
# 或者: from plone.app.linkintegrity.interfaces.ILinkIntegrityInfo import isConfirmedItem [as 別名]
def isLinked(obj):
    """ check if the given content object is linked from another one
        WARNING: don't use this function in your code!!
            it is a helper for the link integrity code and will potentially
            abort the ongoing transaction, giving you unexpected results...
    """
    # first check to see if link integrity handling has been enabled at all
    # and if so, if the removal of the object was already confirmed, i.e.
    # while replaying the request;  unfortunately this makes it necessary
    # to import from plone.app.linkintegrity here, hence the try block...
    try:
        from plone.app.linkintegrity.interfaces import ILinkIntegrityInfo
        info = ILinkIntegrityInfo(obj.REQUEST)
    except (ImportError, TypeError):
        # if p.a.li isn't installed the following check can be cut short...
        return False
    if not info.integrityCheckingEnabled():
        return False
    if info.isConfirmedItem(obj):
        return True
    # otherwise, when not replaying the request already, it is tried to
    # delete the object, making it possible to find out if it was referenced,
    # i.e. in case a link integrity exception was raised
    linked = False
    parent = obj.aq_inner.aq_parent
    try:
        parent.manage_delObjects(obj.getId())
    except OFS.ObjectManager.BeforeDeleteException, e:
        linked = True
開發者ID:dtgit,項目名稱:dtedu,代碼行數:31,代碼來源:utils.py

示例3: referencedObjectRemoved

# 需要導入模塊: from plone.app.linkintegrity.interfaces import ILinkIntegrityInfo [as 別名]
# 或者: from plone.app.linkintegrity.interfaces.ILinkIntegrityInfo import isConfirmedItem [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

示例4: handle_remove_event

# 需要導入模塊: from plone.app.linkintegrity.interfaces import ILinkIntegrityInfo [as 別名]
# 或者: from plone.app.linkintegrity.interfaces.ILinkIntegrityInfo import isConfirmedItem [as 別名]
def handle_remove_event(obj, event):
    """If an object will be removed on the senders instance, we need to create a
    publisher delete job.
    """
    # the event is notified for every subobject, but we only want to check
    # the top object which the users tries to delete
    if obj is not event.object:
        return

    workflow = get_workflow_name(obj)
    if not workflow or workflow not in config.PUBLISHING_WORKFLOWS:
        # we don't have a workflow or the workflow does not publish ever - so we
        # don't need to delete anything on the receiver.
        return

    # the event handler is fired twice (once from link integrity check), but
    # we just want to do our stuff once. And we should only do it if the user
    # already did confirm.
    do_delete = False
    request = getattr(obj, 'REQUEST', None)
    if request is None:
        do_delete = True
    else:
        info = ILinkIntegrityInfo(request)
        if not info.integrityCheckingEnabled():
            do_delete = True
        elif info.isConfirmedItem(obj):
            do_delete = True

    if request.URL.endswith('/sl_delete_object'):
        do_delete = True
    if request.has_key('form.submitted') and \
            request.URL.endswith('/delete_confirmation'):
        do_delete = True
    if request.URL.endswith('/folder_delete'):
        do_delete = True
    if request.has_key('form.button.Cancel'):
        do_delete = True

    # register the job
    if do_delete:
        obj.restrictedTraverse('@@publisher.delete')()
開發者ID:BenoitTalbot,項目名稱:bungeni-portal,代碼行數:44,代碼來源:eventhandlers.py

示例5: isLinked

# 需要導入模塊: from plone.app.linkintegrity.interfaces import ILinkIntegrityInfo [as 別名]
# 或者: from plone.app.linkintegrity.interfaces.ILinkIntegrityInfo import isConfirmedItem [as 別名]
def isLinked(obj):
    """ check if the given content object is linked from another one

        WARNING: this function can be time consuming !!

            It deletes the object in a subtransaction that is rollbacked.
            In other words, the object is kept safe.

            Nevertheless, this implies that it also deletes recursively
            all object's subobjects and references, which can be very
            expensive.
    """
    # first check to see if link integrity handling has been enabled at all
    # and if so, if the removal of the object was already confirmed, i.e.
    # while replaying the request;  unfortunately this makes it necessary
    # to import from plone.app.linkintegrity here, hence the try block...
    try:
        from plone.app.linkintegrity.interfaces import ILinkIntegrityInfo

        info = ILinkIntegrityInfo(obj.REQUEST)
    except (ImportError, TypeError):
        # if p.a.li isn't installed the following check can be cut short...
        return False
    if not info.integrityCheckingEnabled():
        return False
    if info.isConfirmedItem(obj):
        return True
    # otherwise, when not replaying the request already, it is tried to
    # delete the object, making it possible to find out if it was referenced,
    # i.e. in case a link integrity exception was raised
    linked = False
    parent = obj.aq_inner.aq_parent
    try:
        savepoint = transaction.savepoint()
        parent.manage_delObjects(obj.getId())
    except OFS.ObjectManager.BeforeDeleteException:
        linked = True
    except:  # ignore other exceptions, not useful to us at this point
        pass
    finally:
        savepoint.rollback()
    return linked
開發者ID:nrb,項目名稱:Products.CMFPlone,代碼行數:44,代碼來源:utils.py


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