From 68ace6aed9785279792922262aa5b149ed852ac1 Mon Sep 17 00:00:00 2001 From: gforcada Date: Fri, 25 Nov 2016 21:28:45 +0100 Subject: [PATCH] [fc] Repository: plone.protect Branch: refs/heads/master Date: 2016-11-25T17:45:59+01:00 Author: Maurits van Rees (mauritsvanrees) Commit: https://github.com/plone/plone.protect/commit/e273918289b220d6bd384cf28c1ea519dd0eb109 Allow `confirm-action` for all contexts, instead of only Plone Site root. This avoids an error when calling it on a subsite. Fixes https://github.com/plone/plone.protect/issues/51. Files changed: M CHANGES.rst M plone/protect/configure.zcml Repository: plone.protect Branch: refs/heads/master Date: 2016-11-25T21:28:45+01:00 Author: Gil Forcada Codinachs (gforcada) Commit: https://github.com/plone/plone.protect/commit/2be2215047113a86ce36166871ea41afd2cda490 Merge pull request #60 from plone/confirm-view-for-all-contexts Allow `confirm-action` for all contexts, instead of only Plone Site Files changed: M CHANGES.rst M plone/protect/configure.zcml --- last_commit.txt | 145 ++++++++++++++++++++---------------------------- 1 file changed, 60 insertions(+), 85 deletions(-) diff --git a/last_commit.txt b/last_commit.txt index c2256c2441..b08d31f6ae 100644 --- a/last_commit.txt +++ b/last_commit.txt @@ -2,125 +2,100 @@ Repository: plone.protect Branch: refs/heads/master -Date: 2016-11-25T07:15:00+01:00 -Author: Jens W. Klein (jensens) -Commit: https://github.com/plone/plone.protect/commit/36f2a7380beace2c377062531d63062ba48ed4f0 +Date: 2016-11-25T17:45:59+01:00 +Author: Maurits van Rees (mauritsvanrees) +Commit: https://github.com/plone/plone.protect/commit/e273918289b220d6bd384cf28c1ea519dd0eb109 + +Allow `confirm-action` for all contexts, instead of only Plone Site root. -fixes #57 Html must contain body, otherwise plone.protect breaks +This avoids an error when calling it on a subsite. +Fixes https://github.com/plone/plone.protect/issues/51. Files changed: M CHANGES.rst -M plone/protect/auto.py +M plone/protect/configure.zcml diff --git a/CHANGES.rst b/CHANGES.rst -index 254daed..dd39d8a 100644 +index dd39d8a..098b716 100644 --- a/CHANGES.rst +++ b/CHANGES.rst -@@ -16,6 +16,9 @@ Bug fixes: +@@ -14,8 +14,14 @@ New features: + + Bug fixes: ++- Allow ``confirm-action`` for all contexts, instead of only Plone Site root. ++ This avoids an error when calling it on a subsite. ++ Fixes `issue #51 `_. ++ [maurits] ++ - Code Style: utf8-headers, import sorting, new style namespace declaration, autopep8 [jensens] -+- Fix #57: Html must contain "body", otherwise plone.protect breaks. -+ [jensens] + + - Fix #57: Html must contain "body", otherwise plone.protect breaks. + [jensens] - 3.0.22 (2016-11-17) - ------------------- -diff --git a/plone/protect/auto.py b/plone/protect/auto.py -index 3e7cbdf..445aaaf 100644 ---- a/plone/protect/auto.py -+++ b/plone/protect/auto.py -@@ -357,15 +357,17 @@ def transform(self, result, encoding): - if self.site is not None and not root.cssselect('#protect-script'): - # Alternative: add this in the resource registry. - site_url = self.site.absolute_url() -- body = root.cssselect('body')[0] -- protect_script = etree.Element("script") -- protect_script.attrib.update({ -- 'type': "application/javascript", -- 'src': "%s/++resource++protect.js" % site_url, -- 'data-site-url': site_url, -- 'data-token': token, -- 'id': 'protect-script' -- }) -- body.append(protect_script) -+ elements = root.cssselect('body') -+ if len(elements): -+ body = elements[0] -+ protect_script = etree.Element("script") -+ protect_script.attrib.update({ -+ 'type': "application/javascript", -+ 'src': "%s/++resource++protect.js" % site_url, -+ 'data-site-url': site_url, -+ 'data-token': token, -+ 'id': 'protect-script' -+ }) -+ body.append(protect_script) +diff --git a/plone/protect/configure.zcml b/plone/protect/configure.zcml +index d31bd7c..0f7f711 100644 +--- a/plone/protect/configure.zcml ++++ b/plone/protect/configure.zcml +@@ -42,7 +42,7 @@ - return result + -Commit: https://github.com/plone/plone.protect/commit/9ef98811ecfdf23e7f3a76af7b1ab8f4451ad083 +Date: 2016-11-25T21:28:45+01:00 +Author: Gil Forcada Codinachs (gforcada) +Commit: https://github.com/plone/plone.protect/commit/2be2215047113a86ce36166871ea41afd2cda490 -Merge pull request #59 from plone/jensens-fix-57 +Merge pull request #60 from plone/confirm-view-for-all-contexts -Fix #57: Html must contain "body", otherwise plone.protect breaks. +Allow `confirm-action` for all contexts, instead of only Plone Site Files changed: M CHANGES.rst -M plone/protect/auto.py +M plone/protect/configure.zcml diff --git a/CHANGES.rst b/CHANGES.rst -index 254daed..dd39d8a 100644 +index dd39d8a..098b716 100644 --- a/CHANGES.rst +++ b/CHANGES.rst -@@ -16,6 +16,9 @@ Bug fixes: +@@ -14,8 +14,14 @@ New features: + + Bug fixes: ++- Allow ``confirm-action`` for all contexts, instead of only Plone Site root. ++ This avoids an error when calling it on a subsite. ++ Fixes `issue #51 `_. ++ [maurits] ++ - Code Style: utf8-headers, import sorting, new style namespace declaration, autopep8 [jensens] -+- Fix #57: Html must contain "body", otherwise plone.protect breaks. -+ [jensens] + + - Fix #57: Html must contain "body", otherwise plone.protect breaks. + [jensens] - 3.0.22 (2016-11-17) - ------------------- -diff --git a/plone/protect/auto.py b/plone/protect/auto.py -index 3e7cbdf..445aaaf 100644 ---- a/plone/protect/auto.py -+++ b/plone/protect/auto.py -@@ -357,15 +357,17 @@ def transform(self, result, encoding): - if self.site is not None and not root.cssselect('#protect-script'): - # Alternative: add this in the resource registry. - site_url = self.site.absolute_url() -- body = root.cssselect('body')[0] -- protect_script = etree.Element("script") -- protect_script.attrib.update({ -- 'type': "application/javascript", -- 'src': "%s/++resource++protect.js" % site_url, -- 'data-site-url': site_url, -- 'data-token': token, -- 'id': 'protect-script' -- }) -- body.append(protect_script) -+ elements = root.cssselect('body') -+ if len(elements): -+ body = elements[0] -+ protect_script = etree.Element("script") -+ protect_script.attrib.update({ -+ 'type': "application/javascript", -+ 'src': "%s/++resource++protect.js" % site_url, -+ 'data-site-url': site_url, -+ 'data-token': token, -+ 'id': 'protect-script' -+ }) -+ body.append(protect_script) +diff --git a/plone/protect/configure.zcml b/plone/protect/configure.zcml +index d31bd7c..0f7f711 100644 +--- a/plone/protect/configure.zcml ++++ b/plone/protect/configure.zcml +@@ -42,7 +42,7 @@ - return result +