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