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


Python ILinkIntegrityInfo.addBreach方法代碼示例

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


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

示例1: test_delete_content_succeeds_with_link_integrity_breach

# 需要導入模塊: from plone.app.linkintegrity.interfaces import ILinkIntegrityInfo [as 別名]
# 或者: from plone.app.linkintegrity.interfaces.ILinkIntegrityInfo import addBreach [as 別名]
 def test_delete_content_succeeds_with_link_integrity_breach(self):
     doc2 = self.portal[self.portal.invokeFactory(
         'Document',
         id='doc2',
         title='My Document',
     )]
     from plone.app.linkintegrity.interfaces import ILinkIntegrityInfo
     info = ILinkIntegrityInfo(self.layer['request'])
     info.addBreach(doc2, self.doc1)
     service = self.traverse('/plone/doc1', method='DELETE')
     service()
     self.assertEqual(204, info.context.response.status)
     self.assertNotIn('doc1', self.portal.objectIds())
開發者ID:lccruz,項目名稱:plone.restapi,代碼行數:15,代碼來源:test_content_delete.py

示例2: referenceRemoved

# 需要導入模塊: from plone.app.linkintegrity.interfaces import ILinkIntegrityInfo [as 別名]
# 或者: from plone.app.linkintegrity.interfaces.ILinkIntegrityInfo import addBreach [as 別名]
def referenceRemoved(obj, event):
    """ store information about the removed link integrity reference """
    assert IReference.providedBy(obj)
    assert obj is event.object          # just making sure...
    if not obj.relationship in get_protected_relationships():
        return                          # skip for other removed references
    # 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
    storage = ILinkIntegrityInfo(request)
    storage.addBreach(obj.getSourceObject(), obj.getTargetObject())
開發者ID:IMIO,項目名稱:plone.app.referenceintegrity,代碼行數:16,代碼來源:handlers.py

示例3: delete_integrity

# 需要導入模塊: from plone.app.linkintegrity.interfaces import ILinkIntegrityInfo [as 別名]
# 或者: from plone.app.linkintegrity.interfaces.ILinkIntegrityInfo import addBreach [as 別名]
def delete_integrity(context, event):
    request = getRequest()
    if request is not None:
        path = context.getPhysicalPath()
        for base in _ignorepaths(request):
            if tuple(path[:len(base)]) == base:
                # allow deletion of Plone site marked by before_site_delete()
                return
        used_by = InUseBy(context, request)
        if len(used_by) > 0:
            info = ILinkIntegrityInfo(request)
            for brain in used_by._brainmap.values():
                info.addBreach(brain._unrestrictedGetObject(), context)
            raise LinkIntegrityNotificationException(context)
開發者ID:upiq,項目名稱:uu.formlibrary,代碼行數:16,代碼來源:handlers.py

示例4: referenceRemoved

# 需要導入模塊: from plone.app.linkintegrity.interfaces import ILinkIntegrityInfo [as 別名]
# 或者: from plone.app.linkintegrity.interfaces.ILinkIntegrityInfo import addBreach [as 別名]
def referenceRemoved(obj, event):
    """ store information about the removed link integrity reference """
    assert IReference.providedBy(obj)
    assert obj is event.object          # just making sure...
    if not obj.relationship == referencedRelationship:
        return                          # skip for other removed references
    # 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
    storage = ILinkIntegrityInfo(request)
    source = obj.getSourceObject()
    if not IBaseObject.providedBy(source) and hasattr(source, 'context'):
        source = source.context
    target = obj.getTargetObject()
    if not IBaseObject.providedBy(target) and hasattr(target, 'context'):
        target = target.context
    if source is not None and target is not None:
        storage.addBreach(source, target)
開發者ID:jsbueno,項目名稱:plone.app.linkintegrity,代碼行數:23,代碼來源:handlers.py

示例5: search_value_in_objects

# 需要導入模塊: from plone.app.linkintegrity.interfaces import ILinkIntegrityInfo [as 別名]
# 或者: from plone.app.linkintegrity.interfaces.ILinkIntegrityInfo import addBreach [as 別名]
def search_value_in_objects(s_obj, ref, p_types=[], type_fields={}):
    """
        Searching a value (reference to an object like id or uid) in fields of objects.
        Parameters:
            * s_obj : the object that is maybe referenced in another objects fields
            * ref : the value to search in field
            * p_types : portal_types that will be only searched
            * type_fields : dict containing as key portal_type and as value a list of fields that must be searched.
                            If a portal_type is not given, all fields will be searched
    """
    # we check all dexterity objects fields to see if ref is used in
    # we can't check only fields using plonegroup vocabulary because maybe another vocabulary name is used
    # this can be long but this operation is not made so often

    request = aq_get(s_obj, 'REQUEST', None)
    if not request:
        return
    try:
        catalog = api.portal.get_tool('portal_catalog')
    except api.portal.CannotGetPortalError:
        # When deleting site, the portal is no more found...
        return

    storage = ILinkIntegrityInfo(request)

    def list_fields(ptype, filter_interfaces=(IText, ICollection, IChoice)):
        """ return for the portal_type the selected fields """
        if ptype not in type_fields:
            type_fields[ptype] = []
            fti = getUtility(IDexterityFTI, name=ptype)
            for name, fld in getFieldsInOrder(fti.lookupSchema()):
                for iface in filter_interfaces:
                    if iface.providedBy(fld):
                        type_fields[ptype].append(name)
                        break
            # also lookup behaviors
            for behavior_id in fti.behaviors:
                behavior = getUtility(IBehavior, behavior_id).interface
                for name, fld in getFieldsInOrder(behavior):
                    for iface in filter_interfaces:
                        if iface.providedBy(fld):
                            type_fields[ptype].append(name)
                            break
        return type_fields[ptype]

    def check_value(val):
        if isinstance(val, basestring) and val == ref:
            return True
        return False

    def check_attribute(val):
        """ check the attribute value and walk in it """
        if isinstance(val, dict):
            for v in val.values():
                res = check_attribute(v)
                if res:
                    return res
        elif base_hasattr(val, '__iter__'):
            for v in val:
                res = check_attribute(v)
                if res:
                    return res
        elif check_value(val):
            res = [val]
            return res
        return []

    for brain in catalog.unrestrictedSearchResults(portal_types=p_types,
                                                   object_provides=IDexterityContent.__identifier__):
        obj = brain._unrestrictedGetObject()
        ptype = obj.portal_type
        for attr in list_fields(ptype):
            if base_hasattr(obj, attr):
                res = check_attribute(getattr(obj, attr))
                if res:
                    storage.addBreach(obj, s_obj)
                    break
開發者ID:collective,項目名稱:collective.contact.plonegroup,代碼行數:79,代碼來源:subscribers.py


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