Skip to content

Commit

Permalink
Merge pull request #536 from plone/remove-portal_properties
Browse files Browse the repository at this point in the history
Removed portal_properties from documentation and tests.
  • Loading branch information
mauritsvanrees committed Jun 16, 2024
2 parents 8b92390 + 91116db commit b114c58
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 49 deletions.
7 changes: 1 addition & 6 deletions docs/about.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 2 additions & 11 deletions docs/user.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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')
Expand Down
2 changes: 2 additions & 0 deletions news/125.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Removed `portal_properties` from documentation and tests.
[maurits]
41 changes: 16 additions & 25 deletions src/plone/api/tests/test_portal.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down
8 changes: 1 addition & 7 deletions src/plone/api/tests/test_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down

0 comments on commit b114c58

Please sign in to comment.