plone / plone.protect

HTTP protection utilities for the Plone CMS
https://pypi.org/project/plone.protect/
7 stars 8 forks source link

Revert py3 changes that cause possible SyntaxError #76

Closed mauritsvanrees closed 6 years ago

mauritsvanrees commented 6 years ago

This PR is for branch 3.x that I have just created. It is used by coredev 5.0 and 5.1. With plone4.csrffixes it should still be fine for Plone 4.3 as well.

For info on the breakage see mostly issue #74, and a bit #75.

This PR basically reverts PR #72 on branch 3.x, except commit 7edf02d3b16e5c6b03e1288ba1cecfe9bcb4761f which seems harmless (plus the changelog entry, which should remain for historical accuracy).

The py3 changes should remain on master, used by Plone 5.2. But I hope that it can be replaced by code that looks less scary. To quote a comment from the code: "It should probably be updated to use the decorator module."

davisagli commented 6 years ago

I think most of the contortions here are to find the request in the function arguments. We should just use zope.globalrequest.getRequest for that, and use functools.wraps to make sure that the protect decorator has nice properties like keeping the name and docstring of the original function.

jensens commented 6 years ago

I think, because of its importance, we should merge it now and defer further optimizations.

mauritsvanrees commented 6 years ago

Agreed, that is what I meant: any further optimizations should be done on the master branch. But that can be done later. Preferably before 5.2 is out, but that can take a while. :-)