From 91116db81545f9e208aba66c03b8a75e44d95077 Mon Sep 17 00:00:00 2001 From: Maurits van Rees Date: Sun, 16 Jun 2024 00:43:54 +0200 Subject: [PATCH] Removed portal_properties from documentation and tests. --- docs/about.md | 7 +---- docs/user.md | 13 ++-------- news/125.bugfix | 2 ++ src/plone/api/tests/test_portal.py | 41 ++++++++++++------------------ src/plone/api/tests/test_user.py | 8 +----- 5 files changed, 22 insertions(+), 49 deletions(-) create mode 100644 news/125.bugfix diff --git a/docs/about.md b/docs/about.md index cf7a7316..e476b0b7 100644 --- a/docs/about.md +++ b/docs/about.md @@ -70,12 +70,7 @@ In general, importing and using an API looks something like this: % invisible-code-block: python % % from plone import api -% from plone.api.exc import InvalidParameterError -% try: -% api.portal.set_registry_record('plone.use_email_as_login', True) -% except InvalidParameterError: -% portal = api.portal.get() -% portal.portal_properties.site_properties.use_email_as_login = True +% api.portal.set_registry_record('plone.use_email_as_login', True) ```python from plone import api diff --git a/docs/user.md b/docs/user.md index 11362b43..c04ccd0b 100644 --- a/docs/user.md +++ b/docs/user.md @@ -26,12 +26,7 @@ If your portal is configured to use emails as usernames, you just need to pass i % invisible-code-block: python % % from plone import api -% from plone.api.exc import InvalidParameterError -% try: -% api.portal.set_registry_record('plone.use_email_as_login', True) -% except InvalidParameterError: -% portal = api.portal.get() -% portal.portal_properties.site_properties.use_email_as_login = True +% api.portal.set_registry_record('plone.use_email_as_login', True) ```python from plone import api @@ -47,11 +42,7 @@ Otherwise, you also need to pass in the username of the new user. % invisible-code-block: python % -% try: -% api.portal.set_registry_record('plone.use_email_as_login', False) -% except InvalidParameterError: -% portal = api.portal.get() -% portal.portal_properties.site_properties.use_email_as_login = False +% api.portal.set_registry_record('plone.use_email_as_login', False) ```python user = api.user.create(email='jane@plone.org', username='jane') diff --git a/news/125.bugfix b/news/125.bugfix new file mode 100644 index 00000000..1e1def71 --- /dev/null +++ b/news/125.bugfix @@ -0,0 +1,2 @@ +Removed `portal_properties` from documentation and tests. +[maurits] diff --git a/src/plone/api/tests/test_portal.py b/src/plone/api/tests/test_portal.py index 39992127..32bfa810 100644 --- a/src/plone/api/tests/test_portal.py +++ b/src/plone/api/tests/test_portal.py @@ -100,32 +100,23 @@ def setUp(self): def _set_localization_date_format(self): """Set the expected localized date format.""" - from plone.api.exc import InvalidParameterError - name_root = "Products.CMFPlone.i18nl10n.override_dateformat." - try: - portal.set_registry_record( - name=name_root + "Enabled", - value=True, - ) - portal.set_registry_record( - name=name_root + "date_format_long", - value="%b %d, %Y %I:%M %p", - ) - portal.set_registry_record( - name=name_root + "time_format", - value="%I:%M %p", - ) - portal.set_registry_record( - name=name_root + "date_format_short", - value="%b %d, %Y", - ) - except InvalidParameterError: - # before Plone 4.3, date formats were stored in portal_properties - properties = portal.get_tool("portal_properties") - properties.localLongTimeFormat = "%b %d, %Y %I:%M %p" - properties.localTimeOnlyFormat = "%I:%M %p" - properties.localTimeFormat = "%b %d, %Y" + portal.set_registry_record( + name=name_root + "Enabled", + value=True, + ) + portal.set_registry_record( + name=name_root + "date_format_long", + value="%b %d, %Y %I:%M %p", + ) + portal.set_registry_record( + name=name_root + "time_format", + value="%I:%M %p", + ) + portal.set_registry_record( + name=name_root + "date_format_short", + value="%b %d, %Y", + ) def test_get(self): """Test getting the portal object.""" diff --git a/src/plone/api/tests/test_user.py b/src/plone/api/tests/test_user.py index bfc770e3..f876e07a 100644 --- a/src/plone/api/tests/test_user.py +++ b/src/plone/api/tests/test_user.py @@ -42,13 +42,7 @@ def _check_userid_and_username_different(self): self.assertNotEqual(userid, username) def _set_emaillogin(self, value): - from plone.api.exc import InvalidParameterError - - try: - api.portal.set_registry_record("plone.use_email_as_login", value) - except InvalidParameterError: - portal = api.portal.get() - portal.portal_properties.site_properties.use_email_as_login = value + api.portal.set_registry_record("plone.use_email_as_login", value) def test_create_no_email(self): """Test that exception is raised if no email is given."""