Skip to content

Commit

Permalink
disable plone.app.linkintegrity subscribers
Browse files Browse the repository at this point in the history
  • Loading branch information
agitator committed Mar 1, 2017
1 parent 9337238 commit e6b01a9
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 39 deletions.
8 changes: 4 additions & 4 deletions src/collective/contact/core/configure.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -109,15 +109,15 @@
factory=".behaviors.DefaultParentAddress"
name="default" />

<subscriber
<!-- <subscriber
for="plone.app.relationfield.interfaces.IDexterityHasRelations
zope.lifecycleevent.interfaces.IObjectRemovedEvent"
handler=".subscribers.referencedObjectRemoved" />
handler=".subscribers.referencedObjectRemoved" /> -->

<subscriber
<!-- <subscriber
for="z3c.relationfield.interfaces.IHasIncomingRelations
OFS.interfaces.IObjectWillBeRemovedEvent"
handler=".subscribers.referenceRemoved" />
handler=".subscribers.referenceRemoved" /> -->

<permission
id="collective.contact.core.UseParentAddress"
Expand Down
70 changes: 35 additions & 35 deletions src/collective/contact/core/subscribers.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
from zope.intid.interfaces import IIntIds
from zope.schema import getFields

from plone.app.linkintegrity.interfaces import ILinkIntegrityInfo
from plone.app.linkintegrity.handlers import referencedObjectRemoved as \
baseReferencedObjectRemoved
# from plone.app.linkintegrity.interfaces import ILinkIntegrityInfo
# from plone.app.linkintegrity.handlers import referencedObjectRemoved as \
# baseReferencedObjectRemoved
try:
from plone.app.referenceablebehavior.referenceable import IReferenceable
except ImportError:
Expand Down Expand Up @@ -81,38 +81,38 @@ def update_related_with_organization(obj, event=None):
update_related_with_organization(child)


def referenceRemoved(obj, event, toInterface=IContactContent):
"""Store information about the removed link integrity reference.
"""
# inspired from z3c/relationfield/event.py:breakRelations
# and plone/app/linkintegrity/handlers.py:referenceRemoved
# 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)

catalog = component.queryUtility(ICatalog)
intids = component.queryUtility(IIntIds)
if catalog is None or intids is None:
return

# find all relations that point to us
obj_id = intids.queryId(obj)
if obj_id is None:
return

rels = list(catalog.findRelations({'to_id': obj_id}))
for rel in rels:
if toInterface.providedBy(rel.to_object):
storage.addBreach(rel.from_object, rel.to_object)


def referencedObjectRemoved(obj, event):
if not IReferenceable.providedBy(obj):
baseReferencedObjectRemoved(obj, event)
# def referenceRemoved(obj, event, toInterface=IContactContent):
# """Store information about the removed link integrity reference.
# """
# # inspired from z3c/relationfield/event.py:breakRelations
# # and plone/app/linkintegrity/handlers.py:referenceRemoved
# # 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)

# catalog = component.queryUtility(ICatalog)
# intids = component.queryUtility(IIntIds)
# if catalog is None or intids is None:
# return

# # find all relations that point to us
# obj_id = intids.queryId(obj)
# if obj_id is None:
# return

# rels = list(catalog.findRelations({'to_id': obj_id}))
# for rel in rels:
# if toInterface.providedBy(rel.to_object):
# storage.addBreach(rel.from_object, rel.to_object)


# def referencedObjectRemoved(obj, event):
# if not IReferenceable.providedBy(obj):
# baseReferencedObjectRemoved(obj, event)


@grok.subscribe(IContactDetails, IObjectModifiedEvent)
Expand Down

1 comment on commit e6b01a9

@tdesvenain
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cf 112dd95

Please sign in to comment.