Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed portal_properties from documentation and tests. #536

Merged
merged 1 commit into from
Jun 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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