-
-
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.
[fc] Repository: plone.app.vocabularies
Branch: refs/heads/master Date: 2024-06-16T00:54:04+02:00 Author: Maurits van Rees (mauritsvanrees) <[email protected]> Commit: plone/plone.app.vocabularies@96b247b Remove usage of `portal_properties`. In `getForbiddenContentTypes` we used to check `portal_properties.site_properties.forbidden_contenttypes`. Files changed: A news/125.breaking M plone/app/vocabularies/types.py Repository: plone.app.vocabularies Branch: refs/heads/master Date: 2024-06-18T12:09:26+02:00 Author: Maurits van Rees (mauritsvanrees) <[email protected]> Commit: plone/plone.app.vocabularies@1763943 Deprecate `etForbiddenContentTypes, to be removed in Plone 7. Files changed: M news/125.breaking M plone/app/vocabularies/types.py Repository: plone.app.vocabularies Branch: refs/heads/master Date: 2024-06-18T12:01:40-04:00 Author: Jens W. Klein (jensens) <[email protected]> Commit: plone/plone.app.vocabularies@e0a16ce Merge pull request #91 from plone/remove-portal_properties Remove usage of `portal_properties`. Files changed: A news/125.breaking M plone/app/vocabularies/types.py
- Loading branch information
Showing
1 changed file
with
33 additions
and
19 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,52 @@ | ||
Repository: plone.testing | ||
Repository: plone.app.vocabularies | ||
|
||
|
||
Branch: refs/heads/master | ||
Date: 2024-06-17T13:52:16+02:00 | ||
Author: Godefroid Chapelle (gotcha) <[email protected]> | ||
Commit: https://github.com/plone/plone.testing/commit/0374059340e07e7f04878c2954d9938f2941f7a2 | ||
|
||
use BytesIO while setting up test Response | ||
Date: 2024-06-16T00:54:04+02:00 | ||
Author: Maurits van Rees (mauritsvanrees) <[email protected]> | ||
Commit: https://github.com/plone/plone.app.vocabularies/commit/96b247b027e57cfb4a263cace117cd034a805415 | ||
|
||
HTTPResponse uses bytes, not string | ||
Remove usage of `portal_properties`. | ||
|
||
However, sys.stdout uses string | ||
In `getForbiddenContentTypes` we used to check `portal_properties.site_properties.forbidden_contenttypes`. | ||
|
||
Files changed: | ||
A news/fix_makeTestRequest.bugfix | ||
M src/plone/testing/zope.py | ||
A news/125.breaking | ||
M plone/app/vocabularies/types.py | ||
|
||
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/125.breaking b/news/125.breaking\nnew file mode 100644\nindex 0000000..59d68de\n--- /dev/null\n+++ b/news/125.breaking\n@@ -0,0 +1,3 @@\n+Remove usage of `portal_properties`.\n+In `getForbiddenContentTypes` we used to check `portal_properties.site_properties.forbidden_contenttypes`.\n+[maurits]\ndiff --git a/plone/app/vocabularies/types.py b/plone/app/vocabularies/types.py\nindex 57b370c..2f35a40 100644\n--- a/plone/app/vocabularies/types.py\n+++ b/plone/app/vocabularies/types.py\n@@ -17,6 +17,7 @@ def getAllowedContentTypes(context):\n allowable (overall available) types.\n """\n allowable_types = getAllowableContentTypes(context)\n+ # By default the next one is empty, but theoretically someone overwrites it.\n forbidden_types = getForbiddenContentTypes(context)\n allowed_types = [ctype for ctype in allowable_types if ctype not in forbidden_types]\n return allowed_types\n@@ -37,18 +38,14 @@ def getAllowableContentTypes(context):\n \n \n def getForbiddenContentTypes(context):\n- """Method for retrieving the site property \'forbidden_contenttypes\'.\n+ """Get forbidden contenttypes.\n \n This is a list of mime-types not allowed in text input fields.\n+\n+ We used to get this from\n+ portal_properties.site_properties.forbidden_contenttypes\n+ Maybe we should have moved this to portal_registry, but no-one did.\n """\n- portal_properties = getToolByName(context, "portal_properties", None)\n- if portal_properties is not None:\n- return []\n- site_properties = getattr(portal_properties, "site_properties", None)\n- if site_properties is not None:\n- return []\n- if site_properties.hasProperty("forbidden_contenttypes"):\n- return list(site_properties.getProperty("forbidden_contenttypes"))\n return []\n \n \n@@ -115,17 +112,6 @@ class AllowedContentTypesVocabulary:\n ... return (\'text/plain\', \'text/spam\')\n >>> tool.listAvailableTextInputs = listAvailableTextInputs\n >>> context.portal_transforms = tool\n-\n- >>> tool = DummyTool(\'portal_properties\')\n- >>> class DummyProperties(object):\n- ... def hasProperty(self, value):\n- ... return True\n- ...\n- ... def getProperty(self, value):\n- ... return (\'text/spam\', )\n- >>> tool.site_properties = DummyProperties()\n- >>> context.portal_properties = tool\n-\n >>> types = util(context)\n >>> types\n <zope.schema.vocabulary.SimpleVocabulary object at ...>\n' | ||
|
||
Repository: plone.testing | ||
Repository: plone.app.vocabularies | ||
|
||
|
||
Branch: refs/heads/master | ||
Date: 2024-06-18T00:42:19+02:00 | ||
Date: 2024-06-18T12:09:26+02:00 | ||
Author: Maurits van Rees (mauritsvanrees) <[email protected]> | ||
Commit: https://github.com/plone/plone.testing/commit/23d09d2db7d53f50ec64b176f262a6a395c92b83 | ||
Commit: https://github.com/plone/plone.app.vocabularies/commit/17639435ea21c66403aaca72211be17f626e744b | ||
|
||
Deprecate `etForbiddenContentTypes, to be removed in Plone 7. | ||
|
||
Files changed: | ||
M news/125.breaking | ||
M plone/app/vocabularies/types.py | ||
|
||
b'diff --git a/news/125.breaking b/news/125.breaking\nindex 59d68de..98b2c20 100644\n--- a/news/125.breaking\n+++ b/news/125.breaking\n@@ -1,3 +1,4 @@\n-Remove usage of `portal_properties`.\n-In `getForbiddenContentTypes` we used to check `portal_properties.site_properties.forbidden_contenttypes`.\n+Remove usage of ``portal_properties``.\n+In ``getForbiddenContentTypes`` we used to check ``portal_properties.site_properties.forbidden_contenttypes``.\n+Now we return nothing, so deprecate ``getForbiddenContentTypes``, to be removed in Plone 7.\n [maurits]\ndiff --git a/plone/app/vocabularies/types.py b/plone/app/vocabularies/types.py\nindex 2f35a40..73f2d8e 100644\n--- a/plone/app/vocabularies/types.py\n+++ b/plone/app/vocabularies/types.py\n@@ -2,6 +2,7 @@\n from plone.app.vocabularies import PermissiveVocabulary\n from Products.CMFCore.utils import getToolByName\n from zope.component.hooks import getSite\n+from zope.deprecation import deprecate\n from zope.i18n import translate\n from zope.interface import implementer\n from zope.schema.interfaces import IVocabularyFactory\n@@ -37,6 +38,7 @@ def getAllowableContentTypes(context):\n return portal_transforms.listAvailableTextInputs()\n \n \n+@deprecate("Returns nothing by default. Will be removed in Plone 7.")\n def getForbiddenContentTypes(context):\n """Get forbidden contenttypes.\n \n' | ||
|
||
Repository: plone.app.vocabularies | ||
|
||
|
||
Branch: refs/heads/master | ||
Date: 2024-06-18T12:01:40-04:00 | ||
Author: Jens W. Klein (jensens) <[email protected]> | ||
Commit: https://github.com/plone/plone.app.vocabularies/commit/e0a16ce518a6caf45d46c06395f6d9f45f5d65c2 | ||
|
||
Merge pull request #94 from plone/fix_makeTestRequest | ||
Merge pull request #91 from plone/remove-portal_properties | ||
|
||
use BytesIO while setting up test Response | ||
Remove usage of `portal_properties`. | ||
|
||
Files changed: | ||
A news/fix_makeTestRequest.bugfix | ||
M src/plone/testing/zope.py | ||
A news/125.breaking | ||
M plone/app/vocabularies/types.py | ||
|
||
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/125.breaking b/news/125.breaking\nnew file mode 100644\nindex 0000000..98b2c20\n--- /dev/null\n+++ b/news/125.breaking\n@@ -0,0 +1,4 @@\n+Remove usage of ``portal_properties``.\n+In ``getForbiddenContentTypes`` we used to check ``portal_properties.site_properties.forbidden_contenttypes``.\n+Now we return nothing, so deprecate ``getForbiddenContentTypes``, to be removed in Plone 7.\n+[maurits]\ndiff --git a/plone/app/vocabularies/types.py b/plone/app/vocabularies/types.py\nindex 57b370c..73f2d8e 100644\n--- a/plone/app/vocabularies/types.py\n+++ b/plone/app/vocabularies/types.py\n@@ -2,6 +2,7 @@\n from plone.app.vocabularies import PermissiveVocabulary\n from Products.CMFCore.utils import getToolByName\n from zope.component.hooks import getSite\n+from zope.deprecation import deprecate\n from zope.i18n import translate\n from zope.interface import implementer\n from zope.schema.interfaces import IVocabularyFactory\n@@ -17,6 +18,7 @@ def getAllowedContentTypes(context):\n allowable (overall available) types.\n """\n allowable_types = getAllowableContentTypes(context)\n+ # By default the next one is empty, but theoretically someone overwrites it.\n forbidden_types = getForbiddenContentTypes(context)\n allowed_types = [ctype for ctype in allowable_types if ctype not in forbidden_types]\n return allowed_types\n@@ -36,19 +38,16 @@ def getAllowableContentTypes(context):\n return portal_transforms.listAvailableTextInputs()\n \n \n+@deprecate("Returns nothing by default. Will be removed in Plone 7.")\n def getForbiddenContentTypes(context):\n- """Method for retrieving the site property \'forbidden_contenttypes\'.\n+ """Get forbidden contenttypes.\n \n This is a list of mime-types not allowed in text input fields.\n+\n+ We used to get this from\n+ portal_properties.site_properties.forbidden_contenttypes\n+ Maybe we should have moved this to portal_registry, but no-one did.\n """\n- portal_properties = getToolByName(context, "portal_properties", None)\n- if portal_properties is not None:\n- return []\n- site_properties = getattr(portal_properties, "site_properties", None)\n- if site_properties is not None:\n- return []\n- if site_properties.hasProperty("forbidden_contenttypes"):\n- return list(site_properties.getProperty("forbidden_contenttypes"))\n return []\n \n \n@@ -115,17 +114,6 @@ class AllowedContentTypesVocabulary:\n ... return (\'text/plain\', \'text/spam\')\n >>> tool.listAvailableTextInputs = listAvailableTextInputs\n >>> context.portal_transforms = tool\n-\n- >>> tool = DummyTool(\'portal_properties\')\n- >>> class DummyProperties(object):\n- ... def hasProperty(self, value):\n- ... return True\n- ...\n- ... def getProperty(self, value):\n- ... return (\'text/spam\', )\n- >>> tool.site_properties = DummyProperties()\n- >>> context.portal_properties = tool\n-\n >>> types = util(context)\n >>> types\n <zope.schema.vocabulary.SimpleVocabulary object at ...>\n' | ||
|