Skip to content

Commit

Permalink
[fc] Repository: plone.rest
Browse files Browse the repository at this point in the history
Branch: refs/heads/master
Date: 2022-03-24T17:00:29+01:00
Author: Timo Stollenwerk (tisto) <stollenwerk@kitconcept.com>
Commit: plone/plone.rest@f1dce1b

Fix #132 changelog entry

Files changed:
A news/132.bugfix
D news/132.fix
  • Loading branch information
tisto committed Mar 24, 2022
1 parent 3e09e52 commit c727899
Showing 1 changed file with 7 additions and 17 deletions.
24 changes: 7 additions & 17 deletions last_commit.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,15 @@ Repository: plone.rest


Branch: refs/heads/master
Date: 2022-03-24T16:57:37+01:00
Author: Mauro Amico (mamico) <mauro.amico@gmail.com>
Commit: https://github.com/plone/plone.rest/commit/4891ad1ad61f0c9541c07539c2708bc82054fbea
Date: 2022-03-24T17:00:29+01:00
Author: Timo Stollenwerk (tisto) <stollenwerk@kitconcept.com>
Commit: https://github.com/plone/plone.rest/commit/f1dce1b31ab4720f3a467b7896fc82a1c4925e83

redirect with view (#132)

* redirect with view

* black

* black

* changes
Fix #132 changelog entry

Files changed:
A news/132.fix
M plone-5.2.x.cfg
M src/plone/rest/errors.py
M src/plone/rest/tests/test_redirects.py
A news/132.bugfix
D news/132.fix

b'diff --git a/news/132.fix b/news/132.fix\nnew file mode 100644\nindex 0000000..e212318\n--- /dev/null\n+++ b/news/132.fix\n@@ -0,0 +1 @@\n+++api++ traverser should be kept on 30x redirections [mamico]\ndiff --git a/plone-5.2.x.cfg b/plone-5.2.x.cfg\nindex cfd8f76..82f35ea 100644\n--- a/plone-5.2.x.cfg\n+++ b/plone-5.2.x.cfg\n@@ -1,11 +1,12 @@\n [buildout]\n extends =\n base.cfg\n- https://dist.plone.org/release/5.2.4/versions.cfg\n+ https://dist.plone.org/release/5.2.7/versions.cfg\n find-links += https://dist.plone.org/thirdparty/\n versions=versions\n \n [versions]\n+plone.rest =\n black = 21.12b0\n \n # Error: The requirement (\'virtualenv>=20.0.35\') is not allowed by your [versions] constraint (20.0.26)\ndiff --git a/src/plone/rest/errors.py b/src/plone/rest/errors.py\nindex ecfe8a3..ecc6607 100644\n--- a/src/plone/rest/errors.py\n+++ b/src/plone/rest/errors.py\n@@ -180,7 +180,12 @@ def attempt_redirect(self):\n return False\n \n # remove ++api++ traverser\n- old_path = "/".join(filter("++api++".__ne__, old_path_elements))\n+ if "++api++" in old_path_elements:\n+ api_traverser_pos = old_path_elements.index("++api++")\n+ old_path_elements = [el for el in old_path_elements if el != "++api++"]\n+ else:\n+ api_traverser_pos = None\n+ old_path = "/".join(old_path_elements)\n \n # First lets try with query string in cases or content migration\n \n@@ -214,9 +219,9 @@ def attempt_redirect(self):\n url = urllib.parse.SplitResult(*(url[:2] + (url_path,) + url[3:])).geturl()\n else:\n # reinsert ++api++ traverser\n- if "++api++" in old_path_elements:\n+ if api_traverser_pos is not None:\n new_path_elements = new_path.split("/")\n- new_path_elements.insert(old_path_elements.index("++api++"), "++api++")\n+ new_path_elements.insert(api_traverser_pos, "++api++")\n new_path = "/".join(new_path_elements)\n url = self.request.physicalPathToURL(new_path)\n \ndiff --git a/src/plone/rest/tests/test_redirects.py b/src/plone/rest/tests/test_redirects.py\nindex 39b159b..73e7ac7 100644\n--- a/src/plone/rest/tests/test_redirects.py\n+++ b/src/plone/rest/tests/test_redirects.py\n@@ -59,6 +59,19 @@ def test_get_to_moved_item_causes_301_redirect_with_api_traverser(self):\n self.assertEqual("application/json", response.headers["Content-type"])\n self.assertEqual({"id": "folder-new", "method": "GET"}, response.json())\n \n+ def test_get_to_moved_item_causes_301_redirect_with_rest_view(self):\n+ response = requests.get(\n+ self.portal_url + "/++api++/folder-old/@actions",\n+ auth=(SITE_OWNER_NAME, SITE_OWNER_PASSWORD),\n+ allow_redirects=False,\n+ )\n+ self.assertEqual(301, response.status_code)\n+ self.assertEqual(\n+ self.portal_url + "/++api++/folder-new/@actions",\n+ response.headers["Location"],\n+ )\n+ self.assertEqual(b"", response.raw.read())\n+\n def test_post_to_moved_item_causes_308_redirect(self):\n response = requests.post(\n self.portal_url + "/folder-old",\n'
b'diff --git a/news/132.fix b/news/132.bugfix\nsimilarity index 100%\nrename from news/132.fix\nrename to news/132.bugfix\n'

0 comments on commit c727899

Please sign in to comment.