Created
April 10, 2012 10:27
-
-
Save mitchellrj/2350190 to your computer and use it in GitHub Desktop.
Make Plone object undeletable but still work with iterate / stagingbehavior
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<configure xmlns="http://namespaces.zope.org/zope"> | |
<subscriber | |
for=".interfaces.IMyType | |
OFS.interfaces.IObjectWillBeRemovedEvent" | |
handler=".events.event_handler" | |
/> | |
</configure> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from AccessControl import Unauthorized | |
try: | |
from plone.app.iterate.interfaces import CheckinException | |
from plone.app.iterate.interfaces import IObjectCopier | |
HAS_ITERATE = True | |
except ImportError: | |
# No iterate available | |
HAS_ITERATE = False | |
from zope.component import queryAdapter | |
def event_handler(object, event): | |
if HAS_ITERATE: | |
copier = queryAdapter(object, IObjectCopier) | |
baseline = None | |
try: | |
baseline = copier._getBaseline() | |
except CheckinException: | |
pass | |
if baseline is not None: | |
# This is a working copy created by plone.app.iterate / | |
# plone.app.stagingbehavior. We need to be able to move and delete | |
# these. | |
return | |
raise Unauthorized |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment