Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't delete a Plone 4 site after adding collective.elasticsearch in eggs #57

Open
idgserpro opened this issue May 22, 2019 · 2 comments

Comments

@idgserpro
Copy link
Member

How to simulate:

Create a minimalplone 4 instance.

https://github.com/collective/minimalplone4

Create a Plone Site. Delete It in the ZMI.

Now, add collective.elasticsearch to the eggs section. Create a Plone Site. Delete it in the ZMI. You get the traceback:

Traceback (innermost last):
  Module ZPublisher.Publish, line 138, in publish
  Module ZPublisher.mapply, line 77, in mapply
  Module ZPublisher.Publish, line 48, in call_object
  Module OFS.ObjectManager, line 539, in manage_delObjects
  Module OFS.ObjectManager, line 390, in _delObject
  Module zope.event, line 31, in notify
  Module zope.component.event, line 24, in dispatch
  Module zope.component._api, line 136, in subscribers
  Module zope.component.registry, line 321, in subscribers
  Module zope.interface.adapter, line 585, in subscribers
  Module zope.component.event, line 32, in objectEventNotify
  Module zope.component._api, line 136, in subscribers
  Module zope.component.registry, line 321, in subscribers
  Module zope.interface.adapter, line 585, in subscribers
  Module OFS.subscribers, line 101, in dispatchObjectWillBeMovedEvent
  Module zope.container.contained, line 153, in dispatchToSublocations
  Module zope.component._api, line 136, in subscribers
  Module zope.component.registry, line 321, in subscribers
  Module zope.interface.adapter, line 585, in subscribers
  Module Products.CMFCore.CMFCatalogAware, line 271, in handleContentishEvent
  Module Products.Archetypes.CatalogMultiplex, line 49, in unindexObject
  Module collective.elasticsearch.patches, line 15, in uncatalog_object (https://github.com/collective/collective.elasticsearch/blob/3.0.3/collective/elasticsearch/patches.py#L15)
  Module collective.elasticsearch.es, line 219, in uncatalog_object (https://github.com/collective/collective.elasticsearch/blob/3.0.3/collective/elasticsearch/es.py#L219)
  Module plone.api.content, line 2, in get
  Module plone.api.validation, line 112, in wrapped
  Module plone.api.content, line 2, in get
  Module plone.api.validation, line 149, in wrapped
  Module plone.api.content, line 151, in get
  Module plone.api.portal, line 82, in get
CannotGetPortalError: Unable to get the portal object. More info on http://docs.plone.org/develop/plone.api/docs/api/exceptions.html#plone.api.exc.CannotGetPortalError
2019-05-21 14:18:38 INFO SignalHandler Caught signal SIGINT

If you remove collective.elasticsearch from the eggs, you can delete the Plone Site again.

@szakitibi
Copy link

Had the same issue. The source of the problem that patched methods from patches.py are called as soon as collective.elasticsearch is present in the buildout.

This is not a problem with regular events, it is not an issue, since there is a check within ElasticSearchCatalog object for self.enabled.

Plone Site delete is a special case though, and results above error.

Quick fix for this exact issue:

 def uncatalog_object(self, uid, obj=None, *args, **kwargs):
+    from collective.elasticsearch.interfaces import IElasticSearchLayer
+    if not IElasticSearchLayer.providedBy(self.REQUEST):
+        return self.uncatalog_object
     es = ElasticSearchCatalog(self)
     return es.uncatalog_object(uid, obj, *args, **kwargs)

Probably all patched methods should be layer aware.

@idgserpro
Copy link
Member Author

The workaround can be used in a collective.recipe.patch part as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants