-
-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Branch: refs/heads/main Date: 2024-06-18T17:38:12+02:00 Author: Maurits van Rees (mauritsvanrees) <maurits@vanrees.org> Commit: plone/plone.volto@2f42bc4 Do not fail on startup when the requests library is missing. Conditionally load the views to migrate to Volto: only when the ``requests`` library is available. We don't want to make this a hard dependency. If you need the migration views, you should include the ``requests`` package yourself. Fixes plone/plone.volto#152 Files changed: A news/152.bugfix M src/plone/volto/browser/configure.zcml Repository: plone.volto Branch: refs/heads/main Date: 2024-06-18T15:08:17-07:00 Author: David Glick (davisagli) <david@glicksoftware.com> Commit: plone/plone.volto@7df9f28 Merge pull request #154 from plone/maurits-conditional-requests Do not fail on startup when the requests library is missing. Files changed: A news/152.bugfix M src/plone/volto/browser/configure.zcml
- Loading branch information
Showing
1 changed file
with
23 additions
and
22 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,39 @@ | ||
Repository: plone.testing | ||
Repository: plone.volto | ||
|
||
|
||
Branch: refs/heads/master | ||
Date: 2024-06-17T13:52:16+02:00 | ||
Author: Godefroid Chapelle (gotcha) <gotcha@bubblenet.be> | ||
Commit: https://github.com/plone/plone.testing/commit/0374059340e07e7f04878c2954d9938f2941f7a2 | ||
|
||
use BytesIO while setting up test Response | ||
Branch: refs/heads/main | ||
Date: 2024-06-18T17:38:12+02:00 | ||
Author: Maurits van Rees (mauritsvanrees) <maurits@vanrees.org> | ||
Commit: https://github.com/plone/plone.volto/commit/2f42bc45f92784adfa79977544cbb2e7f7b3598f | ||
|
||
HTTPResponse uses bytes, not string | ||
Do not fail on startup when the requests library is missing. | ||
|
||
However, sys.stdout uses string | ||
Conditionally load the views to migrate to Volto: only when the ``requests`` library is available. | ||
We don't want to make this a hard dependency. | ||
If you need the migration views, you should include the ``requests`` package yourself. | ||
Fixes https://github.com/plone/plone.volto/issues/152 | ||
|
||
Files changed: | ||
A news/fix_makeTestRequest.bugfix | ||
M src/plone/testing/zope.py | ||
A news/152.bugfix | ||
M src/plone/volto/browser/configure.zcml | ||
|
||
b'diff --git a/news/fix_makeTestRequest.bugfix b/news/fix_makeTestRequest.bugfix\nnew file mode 100644\nindex 0000000..8432720\n--- /dev/null\n+++ b/news/fix_makeTestRequest.bugfix\n@@ -0,0 +1 @@\n+makeTestRequest: use BytesIO to set up the test Response. @gotcha\ndiff --git a/src/plone/testing/zope.py b/src/plone/testing/zope.py\nindex 52d9df4..2706879 100644\n--- a/src/plone/testing/zope.py\n+++ b/src/plone/testing/zope.py\n@@ -175,8 +175,8 @@ def setRoles(userFolder, userId, roles):\n \n def makeTestRequest(environ=None):\n """Return an HTTPRequest object suitable for testing views."""\n+ from io import BytesIO\n from sys import stdin\n- from sys import stdout\n from zope.publisher.browser import setDefaultSkin\n from ZPublisher.HTTPRequest import HTTPRequest\n from ZPublisher.HTTPResponse import HTTPResponse\n@@ -187,7 +187,7 @@ def makeTestRequest(environ=None):\n environ.setdefault("SERVER_PORT", "80")\n environ.setdefault("REQUEST_METHOD", "GET")\n \n- resp = HTTPResponse(stdout=stdout)\n+ resp = HTTPResponse(stdout=BytesIO())\n req = HTTPRequest(stdin, environ, resp)\n req._steps = ["noobject"] # Fake a published object.\n req["ACTUAL_URL"] = req.get("URL")\n' | ||
b'diff --git a/news/152.bugfix b/news/152.bugfix\nnew file mode 100644\nindex 0000000..34dc4e5\n--- /dev/null\n+++ b/news/152.bugfix\n@@ -0,0 +1,5 @@\n+Do not fail on startup when the ``requests`` library is missing.\n+Conditionally load the views to migrate to Volto: only when the ``requests`` library is available.\n+We don\'t want to make this a hard dependency.\n+If you need the migration views, you should include the ``requests`` package yourself.\n+[maurits]\ndiff --git a/src/plone/volto/browser/configure.zcml b/src/plone/volto/browser/configure.zcml\nindex 78ce7e6..ccebe58 100644\n--- a/src/plone/volto/browser/configure.zcml\n+++ b/src/plone/volto/browser/configure.zcml\n@@ -32,23 +32,25 @@\n zcml:condition="have plone-5"\n />\n \n- <browser:page\n- name="migrate_richtext"\n- for="zope.interface.Interface"\n- class=".migrate_richtext.MigrateRichTextToVoltoBlocks"\n- template="migrate_richtext.pt"\n- permission="cmf.ManagePortal"\n- zcml:condition="have plone-60"\n- />\n+ <configure zcml:condition="installed requests">\n+ <browser:page\n+ name="migrate_richtext"\n+ for="zope.interface.Interface"\n+ class=".migrate_richtext.MigrateRichTextToVoltoBlocks"\n+ template="migrate_richtext.pt"\n+ permission="cmf.ManagePortal"\n+ zcml:condition="have plone-60"\n+ />\n \n- <browser:page\n- name="migrate_to_volto"\n- for="zope.interface.Interface"\n- class=".migrate_to_volto.MigrateToVolto"\n- template="migrate_to_volto.pt"\n- permission="cmf.ManagePortal"\n- zcml:condition="have plone-60"\n- />\n+ <browser:page\n+ name="migrate_to_volto"\n+ for="zope.interface.Interface"\n+ class=".migrate_to_volto.MigrateToVolto"\n+ template="migrate_to_volto.pt"\n+ permission="cmf.ManagePortal"\n+ zcml:condition="have plone-60"\n+ />\n+ </configure>\n \n <browser:viewlet\n name="voltobackendwarning"\n' | ||
|
||
Repository: plone.testing | ||
Repository: plone.volto | ||
|
||
|
||
Branch: refs/heads/master | ||
Date: 2024-06-18T00:42:19+02:00 | ||
Author: Maurits van Rees (mauritsvanrees) <maurits@vanrees.org> | ||
Commit: https://github.com/plone/plone.testing/commit/23d09d2db7d53f50ec64b176f262a6a395c92b83 | ||
Branch: refs/heads/main | ||
Date: 2024-06-18T15:08:17-07:00 | ||
Author: David Glick (davisagli) <david@glicksoftware.com> | ||
Commit: https://github.com/plone/plone.volto/commit/7df9f28766beac1a70d1c00f6b2057ed31d05b4f | ||
|
||
Merge pull request #94 from plone/fix_makeTestRequest | ||
Merge pull request #154 from plone/maurits-conditional-requests | ||
|
||
use BytesIO while setting up test Response | ||
Do not fail on startup when the requests library is missing. | ||
|
||
Files changed: | ||
A news/fix_makeTestRequest.bugfix | ||
M src/plone/testing/zope.py | ||
A news/152.bugfix | ||
M src/plone/volto/browser/configure.zcml | ||
|
||
b'diff --git a/news/fix_makeTestRequest.bugfix b/news/fix_makeTestRequest.bugfix\nnew file mode 100644\nindex 0000000..8432720\n--- /dev/null\n+++ b/news/fix_makeTestRequest.bugfix\n@@ -0,0 +1 @@\n+makeTestRequest: use BytesIO to set up the test Response. @gotcha\ndiff --git a/src/plone/testing/zope.py b/src/plone/testing/zope.py\nindex 52d9df4..2706879 100644\n--- a/src/plone/testing/zope.py\n+++ b/src/plone/testing/zope.py\n@@ -175,8 +175,8 @@ def setRoles(userFolder, userId, roles):\n \n def makeTestRequest(environ=None):\n """Return an HTTPRequest object suitable for testing views."""\n+ from io import BytesIO\n from sys import stdin\n- from sys import stdout\n from zope.publisher.browser import setDefaultSkin\n from ZPublisher.HTTPRequest import HTTPRequest\n from ZPublisher.HTTPResponse import HTTPResponse\n@@ -187,7 +187,7 @@ def makeTestRequest(environ=None):\n environ.setdefault("SERVER_PORT", "80")\n environ.setdefault("REQUEST_METHOD", "GET")\n \n- resp = HTTPResponse(stdout=stdout)\n+ resp = HTTPResponse(stdout=BytesIO())\n req = HTTPRequest(stdin, environ, resp)\n req._steps = ["noobject"] # Fake a published object.\n req["ACTUAL_URL"] = req.get("URL")\n' | ||
b'diff --git a/news/152.bugfix b/news/152.bugfix\nnew file mode 100644\nindex 0000000..34dc4e5\n--- /dev/null\n+++ b/news/152.bugfix\n@@ -0,0 +1,5 @@\n+Do not fail on startup when the ``requests`` library is missing.\n+Conditionally load the views to migrate to Volto: only when the ``requests`` library is available.\n+We don\'t want to make this a hard dependency.\n+If you need the migration views, you should include the ``requests`` package yourself.\n+[maurits]\ndiff --git a/src/plone/volto/browser/configure.zcml b/src/plone/volto/browser/configure.zcml\nindex 78ce7e6..ccebe58 100644\n--- a/src/plone/volto/browser/configure.zcml\n+++ b/src/plone/volto/browser/configure.zcml\n@@ -32,23 +32,25 @@\n zcml:condition="have plone-5"\n />\n \n- <browser:page\n- name="migrate_richtext"\n- for="zope.interface.Interface"\n- class=".migrate_richtext.MigrateRichTextToVoltoBlocks"\n- template="migrate_richtext.pt"\n- permission="cmf.ManagePortal"\n- zcml:condition="have plone-60"\n- />\n+ <configure zcml:condition="installed requests">\n+ <browser:page\n+ name="migrate_richtext"\n+ for="zope.interface.Interface"\n+ class=".migrate_richtext.MigrateRichTextToVoltoBlocks"\n+ template="migrate_richtext.pt"\n+ permission="cmf.ManagePortal"\n+ zcml:condition="have plone-60"\n+ />\n \n- <browser:page\n- name="migrate_to_volto"\n- for="zope.interface.Interface"\n- class=".migrate_to_volto.MigrateToVolto"\n- template="migrate_to_volto.pt"\n- permission="cmf.ManagePortal"\n- zcml:condition="have plone-60"\n- />\n+ <browser:page\n+ name="migrate_to_volto"\n+ for="zope.interface.Interface"\n+ class=".migrate_to_volto.MigrateToVolto"\n+ template="migrate_to_volto.pt"\n+ permission="cmf.ManagePortal"\n+ zcml:condition="have plone-60"\n+ />\n+ </configure>\n \n <browser:viewlet\n name="voltobackendwarning"\n' | ||
|