Skip to content

Commit

Permalink
Merge pull request #323 from plone/plonezope4
Browse files Browse the repository at this point in the history
Fix imports from Globals that was removed in Zope4
  • Loading branch information
jensens committed Jan 31, 2017
2 parents f25a2f3 + 16f30c4 commit 78914c9
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 9 deletions.
3 changes: 3 additions & 0 deletions docs/CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ Bug fixes:
- Support user.get_roles for anonymous users. Refs #339
[jaroel]

- Fix imports from Globals that was removed in Zope4
[pbauer]


1.5.1 (2016-12-06)
------------------
Expand Down
4 changes: 2 additions & 2 deletions src/plone/api/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from AccessControl.SecurityManagement import getSecurityManager
from AccessControl.SecurityManagement import newSecurityManager
from AccessControl.SecurityManagement import setSecurityManager
from App.config import getConfiguration
from contextlib import contextmanager
from pkg_resources import get_distribution
from plone.api import portal
Expand All @@ -12,7 +13,6 @@
from plone.api.validation import required_parameters
from zope.globalrequest import getRequest

import Globals
import traceback


Expand Down Expand Up @@ -181,7 +181,7 @@ def debug_mode():
:Example: :ref:`env_debug_mode_example`
"""
return Globals.DevelopmentMode
return getConfiguration().debug_mode


def test_mode():
Expand Down
6 changes: 5 additions & 1 deletion src/plone/api/portal.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,11 @@
):
PRINTINGMAILHOST_ENABLED = True
else:
PRINTINGMAILHOST_ENABLED = False
# PrintingMailHost only patches in debug mode.
# plone.api.env.debug_mode cannot be used here, because .env imports this
# file
from App.config import getConfiguration
PRINTINGMAILHOST_ENABLED = getConfiguration().debug_mode

MISSING = object()

Expand Down
12 changes: 6 additions & 6 deletions src/plone/api/tests/test_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from plone.app.testing import TEST_USER_ID

import AccessControl
import Globals
import unittest


Expand Down Expand Up @@ -51,7 +50,7 @@ def private_method(self):
pass


Globals.InitializeClass(HasProtectedMethods)
AccessControl.class_init.InitializeClass(HasProtectedMethods)


class TestPloneApiEnv(unittest.TestCase):
Expand Down Expand Up @@ -389,12 +388,13 @@ def test_argument_requirement(self):
api.env.adopt_roles()

def test_debug_mode(self):
"""Tests that returned value is the same as Globals.DevelopmentMode."""
"""Tests that the retured value is the same as
getConfiguration.debug_mode."""
from plone.api.env import debug_mode
import Globals
Globals.DevelopmentMode = True
from App.config import getConfiguration
getConfiguration().debug_mode = True
self.assertEqual(debug_mode(), True)
Globals.DevelopmentMode = False
getConfiguration().debug_mode = False
self.assertEqual(debug_mode(), False)

def test_test_mode(self):
Expand Down

1 comment on commit 78914c9

@jenkins-plone-org
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jensens Jenkins CI reporting about code analysis
See the full report here: http://jenkins.plone.org/job/package-plone.api/26/violations

src/plone/api/content.py:269:1: C901 'delete' is too complex (15)
src/plone/api/content.py:361:1: C901 '_wf_transitions_for' is too complex (13)
src/plone/api/content.py:426:1: C901 'transition' is too complex (13)
src/plone/api/portal.py:288:13: Q000 Remove bad quotes.
src/plone/api/portal.py:289:13: Q000 Remove bad quotes.
src/plone/api/portal.py:330:13: Q000 Remove bad quotes.

Follow these instructions to reproduce it locally.

Please sign in to comment.