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

Unwanted behavior when deleting WC, instead of cancel checkout #63

Open
ewohnlich opened this issue Jul 12, 2018 · 0 comments
Open

Unwanted behavior when deleting WC, instead of cancel checkout #63

ewohnlich opened this issue Jul 12, 2018 · 0 comments

Comments

@ewohnlich
Copy link

Plone 5.0
plone.app.iterate 3.2.0

I ran into an issue where some users were deleting the working copy instead of canceling the checkout. Unfortunately I can't just rely on them using the cancel option and need to find a tech solution. Deleting without canceling causes at least two problems.

  1. The baseline content remains locked, in a way that is not even easily unlocked TTP
  2. When the baseline is checked out again, the new working copy bizarrely declares itself to be both a working copy and its own baseline

I do not think blocking the delete action is the way to go because that is a high level action and other interfaces may provide other ways of deletion (such as the folder contents). Removing the "Delete objects" permission also won't work because deletion is still a part of the cancel checkout process. Instead, I looked to create a delete event listener that would emulate the cleanup part of policy.cancelCheckout as best as I understand it.

<subscriber
        for="plone.dexterity.interfaces.IDexterityContent
             OFS.interfaces.IObjectWillBeRemovedEvent"
        handler=".events.delete_no_checkout"/>
def delete_no_checkout(ob, event):
    """ In case it is deleted without cancel """
    policy = ICheckinCheckoutPolicy(ob, None)
    if policy is not None:
        # simulate policy.cancelCheckout except for the delete part of course
        baseline = policy._getBaseline()
        notify(CancelCheckoutEvent(ob, baseline))

As far as I can tell, this does what i would expect and makes delete and 'cancel' effectively the same. It does not appear to cause adverse affects when properly doing a cancel. The subscribers will be notified twice, but that seems to be fine. I believe the relevant subscribers are in marker.py and locking.py.

delete_result

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

1 participant