diff --git a/plone/__init__.py b/plone/__init__.py
index f48ad105..68c04af4 100644
--- a/plone/__init__.py
+++ b/plone/__init__.py
@@ -1,6 +1,2 @@
-# See http://peak.telecommunity.com/DevCenter/setuptools#namespace-packages
-try:
- __import__('pkg_resources').declare_namespace(__name__)
-except ImportError:
- from pkgutil import extend_path
- __path__ = extend_path(__path__, __name__)
+# -*- coding: utf-8 -*-
+__import__('pkg_resources').declare_namespace(__name__)
diff --git a/plone/app/__init__.py b/plone/app/__init__.py
index f48ad105..de40ea7c 100644
--- a/plone/app/__init__.py
+++ b/plone/app/__init__.py
@@ -1,6 +1 @@
-# See http://peak.telecommunity.com/DevCenter/setuptools#namespace-packages
-try:
- __import__('pkg_resources').declare_namespace(__name__)
-except ImportError:
- from pkgutil import extend_path
- __path__ = extend_path(__path__, __name__)
+__import__('pkg_resources').declare_namespace(__name__)
diff --git a/plone/app/layout/__init__.py b/plone/app/layout/__init__.py
index 792d6005..40a96afc 100644
--- a/plone/app/layout/__init__.py
+++ b/plone/app/layout/__init__.py
@@ -1 +1 @@
-#
+# -*- coding: utf-8 -*-
diff --git a/plone/app/layout/analytics/__init__.py b/plone/app/layout/analytics/__init__.py
index 792d6005..40a96afc 100644
--- a/plone/app/layout/analytics/__init__.py
+++ b/plone/app/layout/analytics/__init__.py
@@ -1 +1 @@
-#
+# -*- coding: utf-8 -*-
diff --git a/plone/app/layout/analytics/tests/__init__.py b/plone/app/layout/analytics/tests/__init__.py
index e69de29b..40a96afc 100644
--- a/plone/app/layout/analytics/tests/__init__.py
+++ b/plone/app/layout/analytics/tests/__init__.py
@@ -0,0 +1 @@
+# -*- coding: utf-8 -*-
diff --git a/plone/app/layout/analytics/tests/base.py b/plone/app/layout/analytics/tests/base.py
index dd5cec0b..b3286974 100644
--- a/plone/app/layout/analytics/tests/base.py
+++ b/plone/app/layout/analytics/tests/base.py
@@ -1,3 +1,4 @@
+# -*- coding: utf-8 -*-
from plone.app.testing.bbb import PloneTestCase
diff --git a/plone/app/layout/analytics/tests/test_doctests.py b/plone/app/layout/analytics/tests/test_doctests.py
index 33dc8af6..9e74c3e3 100644
--- a/plone/app/layout/analytics/tests/test_doctests.py
+++ b/plone/app/layout/analytics/tests/test_doctests.py
@@ -1,8 +1,10 @@
-import unittest
-import doctest
+# -*- coding: utf-8 -*-
+from plone.app.layout.analytics.tests import base
from Testing import ZopeTestCase as ztc
-from plone.app.layout.analytics.tests import base
+import doctest
+import unittest
+
OPTIONFLAGS = (doctest.REPORT_ONLY_FIRST_FAILURE |
doctest.ELLIPSIS |
diff --git a/plone/app/layout/analytics/view.py b/plone/app/layout/analytics/view.py
index 6294f53c..6f5478f8 100644
--- a/plone/app/layout/analytics/view.py
+++ b/plone/app/layout/analytics/view.py
@@ -1,15 +1,14 @@
-from Products.CMFPlone.interfaces import ISiteSchema
+# -*- coding: utf-8 -*-
from plone.registry.interfaces import IRegistry
-
+from Products.CMFPlone.interfaces import ISiteSchema
+from Products.Five.browser import BrowserView
from zope.component import getUtility
-from zope.interface import implements
+from zope.interface import implementer
from zope.viewlet.interfaces import IViewlet
-from Products.Five.browser import BrowserView
-
+@implementer(IViewlet)
class AnalyticsViewlet(BrowserView):
- implements(IViewlet)
def __init__(self, context, request, view, manager):
super(AnalyticsViewlet, self).__init__(context, request)
@@ -25,10 +24,11 @@ def update(self):
def render(self):
"""render the webstats snippet"""
registry = getUtility(IRegistry)
- site_settings = registry.forInterface(ISiteSchema, prefix="plone", check=False)
+ site_settings = registry.forInterface(
+ ISiteSchema, prefix="plone", check=False)
try:
if site_settings.webstats_js:
return site_settings.webstats_js
- return ''
except AttributeError:
- return ''
+ pass
+ return ''
diff --git a/plone/app/layout/dashboard/__init__.py b/plone/app/layout/dashboard/__init__.py
index 792d6005..40a96afc 100644
--- a/plone/app/layout/dashboard/__init__.py
+++ b/plone/app/layout/dashboard/__init__.py
@@ -1 +1 @@
-#
+# -*- coding: utf-8 -*-
diff --git a/plone/app/layout/dashboard/dashboard.py b/plone/app/layout/dashboard/dashboard.py
index c0649b6b..e933628c 100644
--- a/plone/app/layout/dashboard/dashboard.py
+++ b/plone/app/layout/dashboard/dashboard.py
@@ -1,38 +1,37 @@
-from zope.component import getUtility
-from zope import interface
-
+# -*- coding: utf-8 -*-
from AccessControl import getSecurityManager
-from Products.Five.browser import BrowserView
-
-from plone.portlets.interfaces import IPortletManager
-from plone.portlets.constants import USER_CATEGORY, GROUP_CATEGORY
-
from plone.memoize.instance import memoize
-
+from plone.portlets.constants import GROUP_CATEGORY
+from plone.portlets.constants import USER_CATEGORY
+from plone.portlets.interfaces import IPortletManager
+from plone.protect.authenticator import createToken
from Products.CMFCore.utils import getToolByName
-from Products.statusmessages.interfaces import IStatusMessage
from Products.CMFPlone import PloneMessageFactory as _
-from plone.protect.authenticator import createToken
+from Products.Five.browser import BrowserView
+from Products.statusmessages.interfaces import IStatusMessage
+from zope.component import getUtility
+from zope.interface import implementer
+from zope.interface import Interface
-class IDashboard(interface.Interface):
+class IDashboard(Interface):
"""the dashboard display columns of portlet to the loggedin user"""
+@implementer(IDashboard)
class DashboardView(BrowserView):
"""Power the dashboard
"""
- interface.implements(IDashboard)
def __call__(self):
- self.request.set('disable_border',1)
- self.request.set('disable_plone.leftcolumn',1)
- self.request.set('disable_plone.rightcolumn',1)
+ self.request.set('disable_border', 1)
+ self.request.set('disable_plone.leftcolumn', 1)
+ self.request.set('disable_plone.rightcolumn', 1)
if self.can_edit() and self.empty():
message = _(u"info_empty_dashboard",
- default=u"Your dashboard is currently empty. Click the"
- " edit tab to assign some personal"
- " portlets.")
+ default=u"Your dashboard is currently empty. Click the"
+ " edit tab to assign some personal"
+ " portlets.")
IStatusMessage(self.request).add(message)
return self.index()
diff --git a/plone/app/layout/dashboard/user_actions.py b/plone/app/layout/dashboard/user_actions.py
index e4bd2544..102d97b9 100644
--- a/plone/app/layout/dashboard/user_actions.py
+++ b/plone/app/layout/dashboard/user_actions.py
@@ -1,3 +1,4 @@
+# -*- coding: utf-8 -*-
from Products.Five.browser import BrowserView
from zope.component import getMultiAdapter
@@ -7,8 +8,10 @@ class UserActionsView(BrowserView):
"""
def user_actions(self):
- context_state = getMultiAdapter((self.context, self.request),
- name=u'plone_context_state')
+ context_state = getMultiAdapter(
+ (self.context, self.request),
+ name=u'plone_context_state'
+ )
actions = context_state.actions('user')
return actions
diff --git a/plone/app/layout/globals/__init__.py b/plone/app/layout/globals/__init__.py
index e69de29b..40a96afc 100644
--- a/plone/app/layout/globals/__init__.py
+++ b/plone/app/layout/globals/__init__.py
@@ -0,0 +1 @@
+# -*- coding: utf-8 -*-
diff --git a/plone/app/layout/globals/context.py b/plone/app/layout/globals/context.py
index bf10aaa4..cd865de0 100644
--- a/plone/app/layout/globals/context.py
+++ b/plone/app/layout/globals/context.py
@@ -1,35 +1,34 @@
-from zope.interface import implements
-from zope.component import getMultiAdapter
-from zope.component import queryAdapter
-from zope.component import queryMultiAdapter
-from zope.component import getUtility
+# -*- coding: utf-8 -*-
+from Acquisition import aq_base
+from Acquisition import aq_inner
+from Acquisition import aq_parent
+from interfaces import IContextState
from plone.memoize.view import memoize
-
-from Acquisition import aq_base, aq_inner, aq_parent
-from Products.Five.browser import BrowserView
-
-from Products.CMFCore.interfaces import ISiteRoot, IDynamicType
-from Products.CMFDynamicViewFTI.interfaces import IBrowserDefault
-from Products.CMFPlone.interfaces import INonStructuralFolder
-
+from plone.portlets.interfaces import ILocalPortletAssignable
+from plone.registry.interfaces import IRegistry
+from Products.CMFCore.interfaces import IDynamicType
+from Products.CMFCore.interfaces import ISiteRoot
from Products.CMFCore.utils import getToolByName
+from Products.CMFDynamicViewFTI.interfaces import IBrowserDefault
from Products.CMFPlone import utils
-from plone.registry.interfaces import IRegistry
-
-from interfaces import IContextState
+from Products.CMFPlone.interfaces import INonStructuralFolder
+from Products.Five.browser import BrowserView
+from zope.component import getMultiAdapter
+from zope.component import getUtility
+from zope.component import queryAdapter
+from zope.component import queryMultiAdapter
+from zope.interface import implementer
-from plone.portlets.interfaces import ILocalPortletAssignable
BLACKLISTED_PROVIDERS = ('portal_workflow', )
BLACKLISTED_CATEGORIES = ('folder_buttons', 'object_buttons', )
+@implementer(IContextState)
class ContextState(BrowserView):
"""Information about the state of the current context
"""
- implements(IContextState)
-
@memoize
def current_page_url(self):
url = self.current_base_url()
@@ -73,7 +72,8 @@ def view_url(self):
view_url = self.object_url()
portal_type = getattr(aq_base(self.context), 'portal_type', None)
registry = getUtility(IRegistry)
- use_view_action = registry.get('plone.types_use_view_action_in_listings', [])
+ use_view_action = registry.get(
+ 'plone.types_use_view_action_in_listings', [])
if portal_type in use_view_action:
view_url = view_url + '/view'
return view_url
diff --git a/plone/app/layout/globals/interface.py b/plone/app/layout/globals/interface.py
index e58eeac0..64032af2 100644
--- a/plone/app/layout/globals/interface.py
+++ b/plone/app/layout/globals/interface.py
@@ -1,10 +1,12 @@
# -*- coding: utf-8 -*-
from Acquisition import aq_base
-from Products.Five.browser import BrowserView
from interfaces import IInterfaceInformation
from plone.memoize.view import memoize
+from Products.Five.browser import BrowserView
from zope.dottedname.resolve import resolve
-from zope.interface import Interface, implements, providedBy
+from zope.interface import implementer
+from zope.interface import Interface
+from zope.interface import providedBy
from zope.interface.interfaces import IMethod
@@ -47,8 +49,8 @@ def visitBaseInterfaces(iface, lst):
visitBaseInterfaces(iface, lst)
+@implementer(IInterfaceInformation)
class InterfaceInformation(BrowserView):
- implements(IInterfaceInformation)
@memoize
def provides(self, dotted_name):
diff --git a/plone/app/layout/globals/layout.py b/plone/app/layout/globals/layout.py
index 9847879f..7bdbcd83 100644
--- a/plone/app/layout/globals/layout.py
+++ b/plone/app/layout/globals/layout.py
@@ -1,10 +1,4 @@
-import json
-
-from Products.CMFCore.utils import getToolByName
-from Products.CMFPlone.interfaces.controlpanel import ILinkSchema
-from Products.CMFPlone.interfaces.controlpanel import ISiteSchema
-from Products.Five.browser.metaconfigure import ViewMixinForTemplates
-from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile
+# -*- coding: utf-8 -*-
from plone.app.layout.globals.interfaces import ILayoutPolicy
from plone.app.layout.globals.interfaces import IViewView
from plone.app.layout.icons.interfaces import IContentIcon
@@ -13,24 +7,28 @@
from plone.portlets.interfaces import IPortletManager
from plone.portlets.interfaces import IPortletManagerRenderer
from plone.registry.interfaces import IRegistry
-from zope.browserpage.viewpagetemplatefile import (
- ViewPageTemplateFile as ZopeViewPageTemplateFile
-)
+from Products.CMFCore.utils import getToolByName
+from Products.CMFPlone.interfaces.controlpanel import ILinkSchema
+from Products.CMFPlone.interfaces.controlpanel import ISiteSchema
+from Products.Five.browser.metaconfigure import ViewMixinForTemplates
+from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile
+from zope.browserpage.viewpagetemplatefile import ViewPageTemplateFile as ZopeViewPageTemplateFile # noqa
from zope.component import getMultiAdapter
from zope.component import getUtility
from zope.component import queryMultiAdapter
from zope.component import queryUtility
from zope.interface import alsoProvides
-from zope.interface import implements
+from zope.interface import implementer
from zope.publisher.browser import BrowserView
+import json
+
+@implementer(ILayoutPolicy)
class LayoutPolicy(BrowserView):
"""A view that gives access to various layout related functions.
"""
- implements(ILayoutPolicy)
-
def mark_view(self, view):
"""Adds a marker interface to the view if it is "the" view for the
context May only be called from a template.
@@ -88,7 +86,8 @@ def icons_visible(self):
anon = membership.isAnonymousUser()
registry = getUtility(IRegistry)
- settings = registry.forInterface(ISiteSchema, prefix="plone", check=False)
+ settings = registry.forInterface(
+ ISiteSchema, prefix="plone", check=False)
icon_visibility = settings.icon_visibility
if icon_visibility == 'enabled':
@@ -106,7 +105,8 @@ def thumb_visible(self):
membership = getToolByName(context, "portal_membership")
anon = membership.isAnonymousUser()
registry = getUtility(IRegistry)
- settings = registry.forInterface(ISiteSchema, prefix="plone", check=False)
+ settings = registry.forInterface(
+ ISiteSchema, prefix="plone", check=False)
thumb_visibility = settings.thumb_visibility
if thumb_visibility == 'enabled':
@@ -223,10 +223,12 @@ def bodyClass(self, template, view):
else:
user = membership.getAuthenticatedMember()
for role in user.getRolesInContext(self.context):
- body_classes.append('userrole-' + role.lower().replace(' ', '-'))
+ body_classes.append(
+ 'userrole-' + role.lower().replace(' ', '-'))
registry = getUtility(IRegistry)
- settings = registry.forInterface(ISiteSchema, prefix='plone', check=False)
+ settings = registry.forInterface(
+ ISiteSchema, prefix='plone', check=False)
# toolbar classes
try:
diff --git a/plone/app/layout/globals/patterns_settings.py b/plone/app/layout/globals/patterns_settings.py
index cae9da46..e63398e5 100644
--- a/plone/app/layout/globals/patterns_settings.py
+++ b/plone/app/layout/globals/patterns_settings.py
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
from zope.deferredimport import deprecated
+
deprecated(
"Import from Products.CMFPlone.patterns.view instead",
PatternSettings='Products.CMFPlone.patterns.view.PatternSettingsView'
diff --git a/plone/app/layout/globals/portal.py b/plone/app/layout/globals/portal.py
index 55ee6ea9..7964b76f 100644
--- a/plone/app/layout/globals/portal.py
+++ b/plone/app/layout/globals/portal.py
@@ -1,32 +1,30 @@
-from zope.interface import implements
-from zope.component import getUtility
-from zope.component import providedBy
-from zope.component.hooks import getSite
+# -*- coding: utf-8 -*-
+from Acquisition import aq_inner
+from interfaces import IPortalState
+from plone.app.layout.navigation.root import getNavigationRoot
+from plone.app.layout.navigation.root import getNavigationRootObject
+from plone.memoize.view import memoize
+from plone.memoize.view import memoize_contextless
from plone.registry.interfaces import IRegistry
from Products.CMFCore.interfaces import ISiteRoot
-from Products.CMFPlone.interfaces import ISiteSchema
-from plone.memoize.view import memoize_contextless
-from plone.memoize.view import memoize
-
-from Acquisition import aq_inner
from Products.CMFCore.utils import getToolByName
from Products.CMFPlone.interfaces import ILanguageSchema
from Products.CMFPlone.interfaces import ISearchSchema
+from Products.CMFPlone.interfaces import ISiteSchema
from Products.Five.browser import BrowserView
+from zope.component import getUtility
+from zope.component import providedBy
+from zope.component.hooks import getSite
+from zope.interface import implementer
-from plone.app.layout.navigation.root import getNavigationRoot
-from plone.app.layout.navigation.root import getNavigationRootObject
-
-
-from interfaces import IPortalState
RIGHT_TO_LEFT = ['ar', 'fa', 'he', 'ps']
+@implementer(IPortalState)
class PortalState(BrowserView):
"""Information about the state of the portal
"""
- implements(IPortalState)
@memoize_contextless
def portal(self):
@@ -40,7 +38,8 @@ def portal(self):
@memoize_contextless
def portal_title(self):
registry = getUtility(IRegistry)
- settings = registry.forInterface(ISiteSchema, prefix="plone", check=False)
+ settings = registry.forInterface(
+ ISiteSchema, prefix="plone", check=False)
return settings.site_title
@memoize_contextless
diff --git a/plone/app/layout/globals/tests/__init__.py b/plone/app/layout/globals/tests/__init__.py
index e69de29b..40a96afc 100644
--- a/plone/app/layout/globals/tests/__init__.py
+++ b/plone/app/layout/globals/tests/__init__.py
@@ -0,0 +1 @@
+# -*- coding: utf-8 -*-
diff --git a/plone/app/layout/globals/tests/base.py b/plone/app/layout/globals/tests/base.py
index 0badfc14..982856ba 100644
--- a/plone/app/layout/globals/tests/base.py
+++ b/plone/app/layout/globals/tests/base.py
@@ -1,3 +1,4 @@
+# -*- coding: utf-8 -*-
from plone.app.testing.bbb import PloneTestCase
diff --git a/plone/app/layout/globals/tests/test_context.py b/plone/app/layout/globals/tests/test_context.py
index adcd39dc..74b37f27 100644
--- a/plone/app/layout/globals/tests/test_context.py
+++ b/plone/app/layout/globals/tests/test_context.py
@@ -1,12 +1,11 @@
+# -*- coding: utf-8 -*-
from plone.app.layout.globals.tests.base import GlobalsTestCase
from plone.app.testing import TEST_USER_ID
-
-from zope.interface import directlyProvides
+from plone.locking.interfaces import ILockable
from Products.CMFDynamicViewFTI.interfaces import IBrowserDefault
from Products.CMFPlone.interfaces import INonStructuralFolder
from Products.CMFPlone.utils import _createObjectByType
-
-from plone.locking.interfaces import ILockable
+from zope.interface import directlyProvides
class TestContextStateView(GlobalsTestCase):
@@ -223,8 +222,8 @@ def test_is_locked(self):
self.assertEqual(self.dview.is_locked(), False)
ILockable(self.folder.d1).lock()
self.logout()
- # The object is not "locked" if it was locked by the
- # current user
+ # The object is not "locked" if it was locked by the
+ # current user
del self.app.REQUEST.__annotations__
self.assertEqual(self.dview.is_locked(), True)
diff --git a/plone/app/layout/globals/tests/test_interface.py b/plone/app/layout/globals/tests/test_interface.py
index 3a0962c3..3532bae9 100644
--- a/plone/app/layout/globals/tests/test_interface.py
+++ b/plone/app/layout/globals/tests/test_interface.py
@@ -1,12 +1,15 @@
-import unittest
+# -*- coding: utf-8 -*-
+from zope.interface import Attribute
+from zope.interface import Interface
+
import doctest
+import unittest
+
optionflags = doctest.REPORT_ONLY_FIRST_FAILURE | doctest.ELLIPSIS
# Used in tests
-from zope.interface import Attribute, Interface
-
class IZero(Interface):
''' Test interface zero
diff --git a/plone/app/layout/globals/tests/test_layout.py b/plone/app/layout/globals/tests/test_layout.py
index 34caced2..0e487752 100644
--- a/plone/app/layout/globals/tests/test_layout.py
+++ b/plone/app/layout/globals/tests/test_layout.py
@@ -1,3 +1,4 @@
+# -*- coding: utf-8 -*-
from plone.app.layout.globals.tests.base import GlobalsTestCase
from plone.app.layout.navigation.interfaces import INavigationRoot
from plone.portlets.interfaces import IPortletType
diff --git a/plone/app/layout/globals/tests/test_portal.py b/plone/app/layout/globals/tests/test_portal.py
index 9d6c7fc3..38217c0c 100644
--- a/plone/app/layout/globals/tests/test_portal.py
+++ b/plone/app/layout/globals/tests/test_portal.py
@@ -1,14 +1,16 @@
-from Products.CMFPlone.interfaces import ILanguageSchema
-from Products.CMFPlone.interfaces import ISearchSchema
-from Products.CMFPlone.interfaces import ISiteSchema
+# -*- coding: utf-8 -*-
from plone.app.layout.globals.tests.base import GlobalsTestCase
from plone.app.layout.navigation.interfaces import INavigationRoot
from plone.app.layout.navigation.root import getNavigationRoot
from plone.registry.interfaces import IRegistry
+from Products.CMFPlone.interfaces import ILanguageSchema
+from Products.CMFPlone.interfaces import ISearchSchema
+from Products.CMFPlone.interfaces import ISiteSchema
from zope.component import getUtility
from zope.event import notify
from zope.i18n.locales import locales
from zope.traversing.interfaces import BeforeTraverseEvent
+
import zope.interface
diff --git a/plone/app/layout/globals/tests/test_tools.py b/plone/app/layout/globals/tests/test_tools.py
index 6b56ef86..4aefc56f 100644
--- a/plone/app/layout/globals/tests/test_tools.py
+++ b/plone/app/layout/globals/tests/test_tools.py
@@ -1,3 +1,4 @@
+# -*- coding: utf-8 -*-
from plone.app.layout.globals.tests.base import GlobalsTestCase
from Products.CMFPlone.utils import getToolByName
diff --git a/plone/app/layout/globals/tools.py b/plone/app/layout/globals/tools.py
index 9beaa94f..ec1dac7b 100644
--- a/plone/app/layout/globals/tools.py
+++ b/plone/app/layout/globals/tools.py
@@ -1,18 +1,16 @@
-from zope.interface import implements
+# -*- coding: utf-8 -*-
+from interfaces import ITools
from plone.memoize.view import memoize_contextless
-
-from Products.Five.browser import BrowserView
from Products.CMFCore.utils import getToolByName
-
-from interfaces import ITools
+from Products.Five.browser import BrowserView
+from zope.interface import implementer
+@implementer(ITools)
class Tools(BrowserView):
"""Common tools
"""
- implements(ITools)
-
@memoize_contextless
def actions(self):
return getToolByName(self.context, 'portal_actions')
diff --git a/plone/app/layout/icons/__init__.py b/plone/app/layout/icons/__init__.py
index 792d6005..40a96afc 100644
--- a/plone/app/layout/icons/__init__.py
+++ b/plone/app/layout/icons/__init__.py
@@ -1 +1 @@
-#
+# -*- coding: utf-8 -*-
diff --git a/plone/app/layout/icons/icons.py b/plone/app/layout/icons/icons.py
index b0e771ef..354add0d 100644
--- a/plone/app/layout/icons/icons.py
+++ b/plone/app/layout/icons/icons.py
@@ -1,15 +1,14 @@
-from plone.memoize.instance import memoize
-from plone.memoize import view
-from zope.component import getMultiAdapter
-from zope.interface import implements
-from zope.i18n import translate
-
+# -*- coding: utf-8 -*-
from Acquisition import aq_inner
from Acquisition import aq_parent
+from plone.app.layout.icons.interfaces import IContentIcon
+from plone.memoize import view
+from plone.memoize.instance import memoize
from Products.CMFCore.Expression import createExprContext
from Products.CMFCore.utils import getToolByName
-
-from plone.app.layout.icons.interfaces import IContentIcon
+from zope.component import getMultiAdapter
+from zope.i18n import translate
+from zope.interface import implementer
class BaseIcon(object):
@@ -37,8 +36,8 @@ def html_tag(self):
return tag
+@implementer(IContentIcon)
class CatalogBrainContentIcon(BaseIcon):
- implements(IContentIcon)
def __init__(self, context, request, brain):
self.context = context
@@ -101,8 +100,8 @@ def extensions_mimetype(self):
return extensions
+@implementer(IContentIcon)
class CMFContentIcon(BaseIcon):
- implements(IContentIcon)
def __init__(self, context, request, obj):
self.context = context
@@ -133,8 +132,8 @@ def description(self):
return self.obj.portal_type
+@implementer(IContentIcon)
class FTIContentIcon(BaseIcon):
- implements(IContentIcon)
def __init__(self, context, request, obj):
self.context = context
@@ -163,8 +162,8 @@ def description(self):
return self.obj.Title()
+@implementer(IContentIcon)
class PloneSiteContentIcon(BaseIcon):
- implements(IContentIcon)
def __init__(self, context, request, obj):
self.context = context
@@ -190,8 +189,8 @@ def description(self):
return self.obj.Title()
+@implementer(IContentIcon)
class DefaultContentIcon(BaseIcon):
- implements(IContentIcon)
def __init__(self, context, request, obj):
self.context = context
diff --git a/plone/app/layout/icons/interfaces.py b/plone/app/layout/icons/interfaces.py
index 885c05d9..8c580559 100644
--- a/plone/app/layout/icons/interfaces.py
+++ b/plone/app/layout/icons/interfaces.py
@@ -1,4 +1,6 @@
-from zope.interface import Interface, Attribute
+# -*- coding: utf-8 -*-
+from zope.interface import Attribute
+from zope.interface import Interface
class IContentIcon(Interface):
diff --git a/plone/app/layout/links/__init__.py b/plone/app/layout/links/__init__.py
index 792d6005..40a96afc 100644
--- a/plone/app/layout/links/__init__.py
+++ b/plone/app/layout/links/__init__.py
@@ -1 +1 @@
-#
+# -*- coding: utf-8 -*-
diff --git a/plone/app/layout/links/tests/__init__.py b/plone/app/layout/links/tests/__init__.py
index 792d6005..ec51c5a2 100644
--- a/plone/app/layout/links/tests/__init__.py
+++ b/plone/app/layout/links/tests/__init__.py
@@ -1 +1,2 @@
+# -*- coding: utf-8 -*-
#
diff --git a/plone/app/layout/links/tests/test_rssviewlet.py b/plone/app/layout/links/tests/test_rssviewlet.py
index 70d61221..06320ac5 100644
--- a/plone/app/layout/links/tests/test_rssviewlet.py
+++ b/plone/app/layout/links/tests/test_rssviewlet.py
@@ -1,8 +1,9 @@
-from zope.component import getUtility
+# -*- coding: utf-8 -*-
+from plone.app.layout.links.viewlets import RSSViewlet
+from plone.app.layout.viewlets.tests.base import ViewletsTestCase
from plone.registry.interfaces import IRegistry
from Products.CMFPlone.interfaces.syndication import ISiteSyndicationSettings
-from plone.app.layout.viewlets.tests.base import ViewletsTestCase
-from plone.app.layout.links.viewlets import RSSViewlet
+from zope.component import getUtility
class TestRSSViewletView(ViewletsTestCase):
diff --git a/plone/app/layout/links/viewlets.py b/plone/app/layout/links/viewlets.py
index 33f9a880..99884af1 100644
--- a/plone/app/layout/links/viewlets.py
+++ b/plone/app/layout/links/viewlets.py
@@ -1,21 +1,19 @@
-from StringIO import StringIO
-
-from plone.memoize import ram
-from plone.memoize import view
-from plone.memoize.compress import xhtml_compress
-from zope.component import getMultiAdapter
-
+# -*- coding: utf-8 -*-
from Acquisition import aq_inner
-from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile
-
from plone.app.layout.viewlets import ViewletBase
from plone.app.uuid.utils import uuidToObject
-from zope.schema.interfaces import IVocabularyFactory
-from zope.component import getUtility
+from plone.memoize import ram
+from plone.memoize import view
+from plone.memoize.compress import xhtml_compress
from plone.registry.interfaces import IRegistry
from Products.CMFPlone.interfaces import ISecuritySchema
from Products.CMFPlone.interfaces.syndication import IFeedSettings
from Products.CMFPlone.interfaces.syndication import ISiteSyndicationSettings
+from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile
+from StringIO import StringIO
+from zope.component import getMultiAdapter
+from zope.component import getUtility
+from zope.schema.interfaces import IVocabularyFactory
def get_language(context, request):
@@ -119,7 +117,8 @@ def update(self):
continue
obj = uuidToObject(uid)
if obj is None and uid[0] == '/':
- obj = portal.restrictedTraverse(uid.lstrip('/'), None)
+ obj = portal.restrictedTraverse(
+ uid.lstrip('/'), None)
if obj is not None:
self.rsslinks.extend(self.getRssLinks(obj))
self.rsslinks.extend(self.getRssLinks(portal))
diff --git a/plone/app/layout/navigation/defaultpage.py b/plone/app/layout/navigation/defaultpage.py
index 96ef3022..a5c055c2 100644
--- a/plone/app/layout/navigation/defaultpage.py
+++ b/plone/app/layout/navigation/defaultpage.py
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
from zope.deferredimport import deprecated
+
deprecated(
"Import from Products.CMFPlone instead",
DefaultPage='Products.CMFPlone.browser.defaultpage:DefaultPage',
diff --git a/plone/app/layout/navigation/interfaces.py b/plone/app/layout/navigation/interfaces.py
index a94728d4..a2f854cf 100644
--- a/plone/app/layout/navigation/interfaces.py
+++ b/plone/app/layout/navigation/interfaces.py
@@ -3,6 +3,7 @@
from zope.interface import Attribute
from zope.interface import Interface
+
deprecated(
"Import from Products.CMFPlone instead",
IDefaultPage='Products.CMFPlone.interfaces.defaultpage:DefaultPage',
diff --git a/plone/app/layout/navigation/navtree.py b/plone/app/layout/navigation/navtree.py
index ab5fbfbe..d43695c9 100644
--- a/plone/app/layout/navigation/navtree.py
+++ b/plone/app/layout/navigation/navtree.py
@@ -1,22 +1,19 @@
+# -*- coding: utf-8 -*-
# This module contains a function to help build navigation-tree-like structures
# from catalog queries.
-from zope.interface import implements
-
+from plone.app.layout.navigation.interfaces import INavtreeStrategy
from Products.CMFCore.utils import getToolByName
from Products.CMFPlone import utils
-
from types import StringType
-
-from plone.app.layout.navigation.interfaces import INavtreeStrategy
+from zope.interface import implementer
+@implementer(INavtreeStrategy)
class NavtreeStrategyBase(object):
"""Basic navigation tree strategy that does nothing.
"""
- implements(INavtreeStrategy)
-
__allow_access_to_unprotected_subobjects__ = 1
rootPath = None
@@ -158,12 +155,12 @@ def buildFolderTree(context, obj=None, query={},
if navtreeLevel > 1:
navtreeContextPath = pathQuery['query']
navtreeContextPathElements = navtreeContextPath[
- len(portalPath)+1:].split('/')
+ len(portalPath) + 1:].split('/')
# Short-circuit if we won't be able to find this path
if len(navtreeContextPathElements) < (navtreeLevel - 1):
return {'children': []}
rootPath = portalPath + '/' + '/'.join(
- navtreeContextPathElements[:navtreeLevel-1])
+ navtreeContextPathElements[:navtreeLevel - 1])
else:
rootPath = portalPath
else:
@@ -317,7 +314,7 @@ def insertElement(itemPaths, item, forceInsert=False):
# context. Note that we use an unrestricted query: things we don't normally
# have permission to see will be included in the tree.
if strategy.showAllParents and objPath is not None:
- objSubPathElements = objPath[len(rootPath)+1:].split('/')
+ objSubPathElements = objPath[len(rootPath) + 1:].split('/')
parentPaths = []
haveNode = (itemPaths.get(rootPath, {}).get('item', None) is None)
@@ -326,7 +323,7 @@ def insertElement(itemPaths, item, forceInsert=False):
parentPath = rootPath
for i in range(len(objSubPathElements)):
- nodePath = rootPath + '/' + '/'.join(objSubPathElements[:i+1])
+ nodePath = rootPath + '/' + '/'.join(objSubPathElements[:i + 1])
node = itemPaths.get(nodePath, None)
# If we don't have this node, we'll have to get it, if we have it
diff --git a/plone/app/layout/navigation/root.py b/plone/app/layout/navigation/root.py
index eddc6e3d..df1ab9d5 100644
--- a/plone/app/layout/navigation/root.py
+++ b/plone/app/layout/navigation/root.py
@@ -3,9 +3,9 @@
from Acquisition import aq_inner
from Acquisition import aq_parent
from plone.app.layout.navigation.interfaces import INavigationRoot
+from plone.registry.interfaces import IRegistry
from Products.CMFCore.utils import getToolByName
from zope.component import getUtility
-from plone.registry.interfaces import IRegistry
def getNavigationRoot(context, relativeRoot=None):
diff --git a/plone/app/layout/navigation/tests/test_defaultpage.py b/plone/app/layout/navigation/tests/test_defaultpage.py
index f52b3715..fe03f001 100644
--- a/plone/app/layout/navigation/tests/test_defaultpage.py
+++ b/plone/app/layout/navigation/tests/test_defaultpage.py
@@ -1,9 +1,10 @@
# -*- coding: utf-8 -*-
-from zope.component import getUtility
from plone.app.layout.testing import INTEGRATION_TESTING
from plone.app.testing import setRoles
from plone.app.testing import TEST_USER_ID
from plone.registry.interfaces import IRegistry
+from zope.component import getUtility
+
import unittest
diff --git a/plone/app/layout/navigation/tests/test_root.py b/plone/app/layout/navigation/tests/test_root.py
index 1b1fa858..d86c3e36 100644
--- a/plone/app/layout/navigation/tests/test_root.py
+++ b/plone/app/layout/navigation/tests/test_root.py
@@ -1,17 +1,17 @@
-from plone.app.layout.navigation.root import getNavigationRootObject
-
-from plone.app.testing.bbb import PloneTestCase
-
-
-class NavigationRootTestCase(PloneTestCase):
- """base test case with convenience methods for all navigation root tests"""
-
- def test_getNavigationRootObject_no_context(self):
- '''
- If you don't know the context then you also don't know what the
- navigation root is.
- '''
- self.assertEqual(
- None,
- getNavigationRootObject(None, self.portal)
- )
+# -*- coding: utf-8 -*-
+from plone.app.layout.navigation.root import getNavigationRootObject
+from plone.app.testing.bbb import PloneTestCase
+
+
+class NavigationRootTestCase(PloneTestCase):
+ """base test case with convenience methods for all navigation root tests"""
+
+ def test_getNavigationRootObject_no_context(self):
+ '''
+ If you don't know the context then you also don't know what the
+ navigation root is.
+ '''
+ self.assertEqual(
+ None,
+ getNavigationRootObject(None, self.portal)
+ )
diff --git a/plone/app/layout/nextprevious/__init__.py b/plone/app/layout/nextprevious/__init__.py
index e69de29b..40a96afc 100644
--- a/plone/app/layout/nextprevious/__init__.py
+++ b/plone/app/layout/nextprevious/__init__.py
@@ -0,0 +1 @@
+# -*- coding: utf-8 -*-
diff --git a/plone/app/layout/nextprevious/interfaces.py b/plone/app/layout/nextprevious/interfaces.py
index 6de1effb..ee16e090 100644
--- a/plone/app/layout/nextprevious/interfaces.py
+++ b/plone/app/layout/nextprevious/interfaces.py
@@ -1,3 +1,4 @@
+# -*- coding: utf-8 -*-
from zope.interface import Interface
from zope.schema import Bool
diff --git a/plone/app/layout/nextprevious/view.py b/plone/app/layout/nextprevious/view.py
index 84b6a4ec..6be1bd0d 100644
--- a/plone/app/layout/nextprevious/view.py
+++ b/plone/app/layout/nextprevious/view.py
@@ -1,11 +1,11 @@
-from zope.component import getMultiAdapter
-
-from plone.app.layout.viewlets import ViewletBase
+# -*- coding: utf-8 -*-
+from Acquisition import aq_inner
+from Acquisition import aq_parent
from plone.app.layout.nextprevious.interfaces import INextPreviousProvider
-
+from plone.app.layout.viewlets import ViewletBase
from Products.Five.browser import BrowserView
from Products.Five.browser.pagetemplatefile import ZopeTwoPageTemplateFile
-from Acquisition import aq_inner, aq_parent
+from zope.component import getMultiAdapter
class NextPreviousView(BrowserView):
diff --git a/plone/app/layout/sitemap/__init__.py b/plone/app/layout/sitemap/__init__.py
index 792d6005..40a96afc 100644
--- a/plone/app/layout/sitemap/__init__.py
+++ b/plone/app/layout/sitemap/__init__.py
@@ -1 +1 @@
-#
+# -*- coding: utf-8 -*-
diff --git a/plone/app/layout/sitemap/sitemap.py b/plone/app/layout/sitemap/sitemap.py
index 03493648..d8bfd600 100644
--- a/plone/app/layout/sitemap/sitemap.py
+++ b/plone/app/layout/sitemap/sitemap.py
@@ -1,18 +1,16 @@
+# -*- coding: utf-8 -*-
from BTrees.OOBTree import OOBTree
-from Products.Five import BrowserView
-from zope.publisher.interfaces import NotFound
+from cStringIO import StringIO
+from gzip import GzipFile
+from plone.memoize import ram
+from plone.registry.interfaces import IRegistry
from Products.CMFCore.utils import getToolByName
from Products.CMFPlone.interfaces import IPloneSiteRoot
+from Products.CMFPlone.interfaces import ISiteSchema
+from Products.Five import BrowserView
from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile
-
from zope.component import getUtility
-from plone.registry.interfaces import IRegistry
-from Products.CMFPlone.interfaces import ISiteSchema
-
-from gzip import GzipFile
-from cStringIO import StringIO
-
-from plone.memoize import ram
+from zope.publisher.interfaces import NotFound
def _render_cachekey(fun, self):
@@ -74,9 +72,9 @@ def objects(self):
yield {
'loc': loc,
'lastmod': lastmod,
- #'changefreq': 'always',
- # hourly/daily/weekly/monthly/yearly/never
- #'prioriy': 0.5, # 0.0 to 1.0
+ # 'changefreq': 'always',
+ # hourly/daily/weekly/monthly/yearly/never
+ # 'prioriy': 0.5, # 0.0 to 1.0
}
query['is_default_page'] = False
@@ -94,9 +92,9 @@ def objects(self):
yield {
'loc': loc,
'lastmod': lastmod,
- #'changefreq': 'always',
- # hourly/daily/weekly/monthly/yearly/never
- #'prioriy': 0.5, # 0.0 to 1.0
+ # 'changefreq': 'always',
+ # hourly/daily/weekly/monthly/yearly/never
+ # 'prioriy': 0.5, # 0.0 to 1.0
}
@ram.cache(_render_cachekey)
@@ -118,6 +116,8 @@ def __call__(self):
if not settings.enable_sitemap:
raise NotFound(self.context, self.filename, self.request)
- self.request.response.setHeader('Content-Type',
- 'application/octet-stream')
+ self.request.response.setHeader(
+ 'Content-Type',
+ 'application/octet-stream'
+ )
return self.generate()
diff --git a/plone/app/layout/sitemap/tests/__init__.py b/plone/app/layout/sitemap/tests/__init__.py
index 792d6005..ec51c5a2 100644
--- a/plone/app/layout/sitemap/tests/__init__.py
+++ b/plone/app/layout/sitemap/tests/__init__.py
@@ -1 +1,2 @@
+# -*- coding: utf-8 -*-
#
diff --git a/plone/app/layout/sitemap/tests/test_sitemap.py b/plone/app/layout/sitemap/tests/test_sitemap.py
index 634ef900..c733e54e 100644
--- a/plone/app/layout/sitemap/tests/test_sitemap.py
+++ b/plone/app/layout/sitemap/tests/test_sitemap.py
@@ -1,22 +1,18 @@
+# -*- coding: utf-8 -*-
+from DateTime import DateTime
+from gzip import GzipFile
+from plone.app.layout.navigation.interfaces import INavigationRoot
+from plone.app.testing.bbb import PloneTestCase
from plone.registry.interfaces import IRegistry
-from zope.component import getUtility
-from Products.CMFPlone.interfaces import ISiteSchema
+from Products.CMFCore.utils import getToolByName
from Products.CMFPlone.interfaces import ISearchSchema
-
-from gzip import GzipFile
+from Products.CMFPlone.interfaces import ISiteSchema
from StringIO import StringIO
-
-from DateTime import DateTime
from zope.component import getMultiAdapter
+from zope.component import getUtility
from zope.interface import alsoProvides
from zope.publisher.interfaces import INotFound
-from plone.app.layout.navigation.interfaces import INavigationRoot
-
-from Products.CMFCore.utils import getToolByName
-
-from plone.app.testing.bbb import PloneTestCase
-
class SiteMapTestCase(PloneTestCase):
"""base test case with convenience methods for all sitemap tests"""
diff --git a/plone/app/layout/testing.py b/plone/app/layout/testing.py
index ec288c34..4c6b15e3 100644
--- a/plone/app/layout/testing.py
+++ b/plone/app/layout/testing.py
@@ -1,8 +1,7 @@
# -*- coding: utf-8 -*-
-
+from plone.app.contenttypes.testing import PLONE_APP_CONTENTTYPES_FIXTURE
from plone.app.testing import FunctionalTesting
from plone.app.testing import IntegrationTesting
-from plone.app.contenttypes.testing import PLONE_APP_CONTENTTYPES_FIXTURE
from plone.app.testing import PloneSandboxLayer
diff --git a/plone/app/layout/viewlets/__init__.py b/plone/app/layout/viewlets/__init__.py
index 1f72b6b9..6f580f39 100644
--- a/plone/app/layout/viewlets/__init__.py
+++ b/plone/app/layout/viewlets/__init__.py
@@ -1 +1,2 @@
+# -*- coding: utf-8 -*-
from common import ViewletBase # noqa
diff --git a/plone/app/layout/viewlets/common.py b/plone/app/layout/viewlets/common.py
index 0dfad995..423e6c65 100644
--- a/plone/app/layout/viewlets/common.py
+++ b/plone/app/layout/viewlets/common.py
@@ -1,38 +1,37 @@
+# -*- coding: utf-8 -*-
+from AccessControl import getSecurityManager
+from Acquisition import aq_base
+from Acquisition import aq_inner
from cgi import escape
from datetime import date
-from urllib import unquote
-
-from plone.registry.interfaces import IRegistry
-
+from plone.app.layout.globals.interfaces import IViewView
+from plone.app.layout.navigation.root import getNavigationRootObject
from plone.memoize.view import memoize
+from plone.protect.utils import addTokenToUrl
+from plone.registry.interfaces import IRegistry
+from Products.CMFCore.utils import getToolByName
+from Products.CMFPlone.interfaces import IPloneSiteRoot
+from Products.CMFPlone.interfaces import ISearchSchema
+from Products.CMFPlone.interfaces import ISiteSchema
+from Products.CMFPlone.utils import getSiteLogo
+from Products.CMFPlone.utils import safe_unicode
+from Products.Five.browser import BrowserView
+from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile
+from urllib import unquote
from zope.component import getMultiAdapter
-from zope.component import queryMultiAdapter
from zope.component import getUtility
+from zope.component import queryMultiAdapter
from zope.deprecation.deprecation import deprecate
from zope.i18n import translate
-from zope.interface import implements, alsoProvides
+from zope.interface import alsoProvides
+from zope.interface import implementer
from zope.viewlet.interfaces import IViewlet
-from AccessControl import getSecurityManager
-from Acquisition import aq_base, aq_inner
-
-from Products.CMFCore.utils import getToolByName
-from Products.CMFPlone.interfaces import ISiteSchema
-from Products.CMFPlone.interfaces import ISearchSchema
-from Products.CMFPlone.utils import safe_unicode, getSiteLogo
-from Products.CMFPlone.interfaces import IPloneSiteRoot
-from Products.Five.browser import BrowserView
-from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile
-
-from plone.app.layout.globals.interfaces import IViewView
-from plone.app.layout.navigation.root import getNavigationRootObject
-from plone.protect.utils import addTokenToUrl
-
+@implementer(IViewlet)
class ViewletBase(BrowserView):
""" Base class with common functions for link viewlets.
"""
- implements(IViewlet)
def __init__(self, context, request, view, manager=None):
super(ViewletBase, self).__init__(context, request)
@@ -208,7 +207,8 @@ def update(self):
def selectedTabs(self, default_tab='index_html', portal_tabs=()):
portal = getToolByName(self.context, 'portal_url').getPortalObject()
- plone_url = getNavigationRootObject(self.context, portal).absolute_url()
+ plone_url = getNavigationRootObject(
+ self.context, portal).absolute_url()
plone_url_len = len(plone_url)
request = self.request
valid_actions = []
@@ -258,8 +258,8 @@ def update(self):
'title': action['title'],
'href': action['url'],
'id': 'personaltools-{}'.format(action['id']),
- 'target': 'link_target' in action and action['link_target'] or None,
- }
+ 'target': action.get('link_target', None),
+ }
modal = action.get('modal')
if modal:
info['class'] = 'pat-plone-modal'
@@ -469,13 +469,15 @@ def render_footer_portlets(self):
You might ask, why is this necessary. Well, let me tell you a story...
plone.app.portlets, in order to provide @@manage-portlets on a context,
- overrides the IPortletRenderer for the IManageContextualPortletsView view.
+ overrides the IPortletRenderer for the IManageContextualPortletsView
+ view.
See plone.portlets and plone.app.portlets
- Seems fine right? Well, most of the time it is. Except, here. Previously,
- we were just using the syntax like `provider:plone.footerportlets` to
- render the footer portlets. Since this tal expression was inside
- a viewlet, the view is no longer IManageContextualPortletsView when
+ Seems fine right? Well, most of the time it is. Except, here.
+ Previously, we were just using the syntax like
+ `provider:plone.footerportlets` to render the footer portlets.
+ Since this tal expression was inside a viewlet,
+ the view is no longer IManageContextualPortletsView when
visiting @@manage-portlets. Instead, it was IViewlet.
See zope.contentprovider
@@ -485,6 +487,8 @@ def render_footer_portlets(self):
See zope.contentprovider
"""
portlet_manager = getMultiAdapter(
- (self.context, self.request, self.__parent__), name='plone.footerportlets')
+ (self.context, self.request, self.__parent__),
+ name='plone.footerportlets'
+ )
portlet_manager.update()
return portlet_manager.render()
diff --git a/plone/app/layout/viewlets/content.py b/plone/app/layout/viewlets/content.py
index e9afc21d..dabcb602 100644
--- a/plone/app/layout/viewlets/content.py
+++ b/plone/app/layout/viewlets/content.py
@@ -1,15 +1,16 @@
-import logging
-
-from plone.memoize.instance import memoize
-from zope.component import getMultiAdapter, queryMultiAdapter
-
+# -*- coding: utf-8 -*-
from AccessControl import getSecurityManager
from Acquisition import aq_inner
from DateTime import DateTime
+from plone.app.content.browser.interfaces import IFolderContentsView
+from plone.app.layout.globals.interfaces import IViewView
+from plone.app.layout.viewlets import ViewletBase
+from plone.app.multilingual.browser.vocabularies import translated_languages
+from plone.app.multilingual.interfaces import ITranslatable
+from plone.app.multilingual.interfaces import ITranslationManager
+from plone.memoize.instance import memoize
from plone.protect.authenticator import createToken
from plone.registry.interfaces import IRegistry
-from Products.Five.browser import BrowserView
-from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile
from Products.CMFCore.utils import _checkPermission
from Products.CMFCore.utils import getToolByName
from Products.CMFCore.WorkflowCore import WorkflowException
@@ -19,14 +20,16 @@
from Products.CMFPlone.interfaces import ISiteSchema
from Products.CMFPlone.utils import base_hasattr
from Products.CMFPlone.utils import log
+from Products.Five.browser import BrowserView
+from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile
+from zope.component import getMultiAdapter
from zope.component import getUtility
+from zope.component import queryMultiAdapter
-from plone.app.layout.globals.interfaces import IViewView
-from plone.app.layout.viewlets import ViewletBase
-from plone.app.content.browser.interfaces import IFolderContentsView
-
+import logging
import pkg_resources
+
try:
pkg_resources.get_distribution('plone.app.relationfield')
except pkg_resources.DistributionNotFound:
@@ -35,15 +38,8 @@
from plone.app.relationfield.behavior import IRelatedItems
HAS_RELATIONFIELD = True
-try:
- pkg_resources.get_distribution('plone.app.multilingual')
-except pkg_resources.DistributionNotFound:
- HAS_PAM = False
-else:
- HAS_PAM = True
- from plone.app.multilingual.interfaces import ITranslatable
- from plone.app.multilingual.interfaces import ITranslationManager
- from plone.app.multilingual.browser.vocabularies import translated_languages
+# XXX needs refactoring, since Plone 5 we have PAM in core.
+HAS_PAM = True
class DocumentActionsViewlet(ViewletBase):
@@ -162,11 +158,15 @@ def get_translations(self):
cts = []
if ITranslatable.providedBy(self.context):
t_langs = translated_languages(self.context)
- context_translations = ITranslationManager(self.context).get_translations()
+ context_translations = ITranslationManager(
+ self.context).get_translations()
for lang in t_langs:
- cts.append(dict(lang_native=lang.title,
- url=context_translations[lang.value].absolute_url()))
-
+ cts.append(
+ dict(
+ lang_native=lang.title,
+ url=context_translations[lang.value].absolute_url()
+ )
+ )
return cts
@@ -282,10 +282,15 @@ def get_translations(self):
cts = []
if ITranslatable.providedBy(self.context):
t_langs = translated_languages(self.context)
- context_translations = ITranslationManager(self.context).get_translations()
+ context_translations = ITranslationManager(
+ self.context).get_translations()
for lang in t_langs:
- cts.append(dict(lang_native=lang.title,
- url=context_translations[lang.value].absolute_url()))
+ cts.append(
+ dict(
+ lang_native=lang.title,
+ url=context_translations[lang.value].absolute_url()
+ )
+ )
return cts
@@ -438,7 +443,8 @@ def revisionHistory(self):
portal_diff = getToolByName(context, "portal_diff", None)
can_diff = portal_diff is not None \
and len(portal_diff.getDiffForPortalType(context.portal_type)) > 0
- can_revert = _checkPermission('CMFEditions: Revert to previous versions', context)
+ can_revert = _checkPermission(
+ 'CMFEditions: Revert to previous versions', context)
def morphVersionDataToHistoryFormat(vdata, version_id):
meta = vdata["metadata"]["sys_metadata"]
@@ -503,10 +509,15 @@ def fullHistory(self):
def toLocalizedTime(self, time, long_format=None, time_only=None):
"""Convert time to localized time
"""
- # util = getToolByName(self.context, 'translation_service')
return DateTime(time).ISO()
- # return util.ulocalized_time(time, long_format, time_only, self.context,
- # domain='plonelocales')
+ # util = getToolByName(self.context, 'translation_service')
+ # return util.ulocalized_time(
+ # time,
+ # long_format,
+ # time_only,
+ # self.context,
+ # domain='plonelocales'
+ # )
class ContentHistoryView(ContentHistoryViewlet):
diff --git a/plone/app/layout/viewlets/globalstatusmessage.py b/plone/app/layout/viewlets/globalstatusmessage.py
index 945b4c7c..c1eeb5fe 100644
--- a/plone/app/layout/viewlets/globalstatusmessage.py
+++ b/plone/app/layout/viewlets/globalstatusmessage.py
@@ -1,5 +1,6 @@
-from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile
+# -*- coding: utf-8 -*-
from plone.app.layout.viewlets.common import ViewletBase
+from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile
from Products.statusmessages.interfaces import IStatusMessage
diff --git a/plone/app/layout/viewlets/httpheaders.py b/plone/app/layout/viewlets/httpheaders.py
index 8fec7073..4b082653 100644
--- a/plone/app/layout/viewlets/httpheaders.py
+++ b/plone/app/layout/viewlets/httpheaders.py
@@ -1,3 +1,4 @@
+# -*- coding: utf-8 -*-
from plone.app.layout.viewlets.common import ViewletBase
diff --git a/plone/app/layout/viewlets/interfaces.py b/plone/app/layout/viewlets/interfaces.py
index 69c854a4..87ea8421 100644
--- a/plone/app/layout/viewlets/interfaces.py
+++ b/plone/app/layout/viewlets/interfaces.py
@@ -1,3 +1,4 @@
+# -*- coding: utf-8 -*-
from zope.viewlet.interfaces import IViewletManager
diff --git a/plone/app/layout/viewlets/social.py b/plone/app/layout/viewlets/social.py
index 4256cc4c..e05dab8b 100644
--- a/plone/app/layout/viewlets/social.py
+++ b/plone/app/layout/viewlets/social.py
@@ -1,14 +1,14 @@
-from Products.CMFPlone.interfaces import ISocialMediaSchema
-from Products.CMFPlone.interfaces.syndication import IFeedItem
-from Products.CMFPlone.utils import getSiteLogo
-from Products.CMFPlone.browser.syndication.adapters import FolderFeed, BaseItem
-
+# -*- coding: utf-8 -*-
from plone.app.layout.viewlets.common import TitleViewlet
from plone.memoize.view import memoize
from plone.registry.interfaces import IRegistry
-
-from zope.component import queryMultiAdapter
+from Products.CMFPlone.browser.syndication.adapters import BaseItem
+from Products.CMFPlone.browser.syndication.adapters import FolderFeed
+from Products.CMFPlone.interfaces import ISocialMediaSchema
+from Products.CMFPlone.interfaces.syndication import IFeedItem
+from Products.CMFPlone.utils import getSiteLogo
from zope.component import getUtility
+from zope.component import queryMultiAdapter
from zope.component.hooks import getSite
diff --git a/plone/app/layout/viewlets/tests/base.py b/plone/app/layout/viewlets/tests/base.py
index 44cb0160..f579fbdb 100644
--- a/plone/app/layout/viewlets/tests/base.py
+++ b/plone/app/layout/viewlets/tests/base.py
@@ -1,3 +1,4 @@
+# -*- coding: utf-8 -*-
from plone.app.testing.bbb import PloneTestCase
diff --git a/plone/app/layout/viewlets/tests/test_content.py b/plone/app/layout/viewlets/tests/test_content.py
index d4e51d23..f9310ee6 100644
--- a/plone/app/layout/viewlets/tests/test_content.py
+++ b/plone/app/layout/viewlets/tests/test_content.py
@@ -1,3 +1,4 @@
+# -*- coding: utf-8 -*-
from DateTime import DateTime
from plone.app.layout.viewlets.content import ContentRelatedItems
from plone.app.layout.viewlets.content import DocumentBylineViewlet
@@ -12,6 +13,7 @@
from zope.interface import Interface
from zope.intid.interfaces import IIntIds
+
try:
import pkg_resources
pkg_resources.get_distribution('plone.app.relationfield')
@@ -31,6 +33,7 @@ class TestDocumentBylineViewletView(ViewletsTestCase):
"""
Test the document by line viewlet
"""
+
def afterSetUp(self):
self.folder.invokeFactory('Document', 'doc1', title='Document 1')
self.context = self.folder['doc1']
@@ -96,6 +99,7 @@ class TestHistoryBylineViewletView(ViewletsTestCase):
"""
Test the document by line viewlet
"""
+
def afterSetUp(self):
self.folder.invokeFactory('Document', 'doc1', title='Document 1')
self.context = self.folder['doc1']
diff --git a/plone/app/layout/viewlets/tests/test_functional.py b/plone/app/layout/viewlets/tests/test_functional.py
index fb431907..e8167960 100644
--- a/plone/app/layout/viewlets/tests/test_functional.py
+++ b/plone/app/layout/viewlets/tests/test_functional.py
@@ -3,11 +3,12 @@
These test are only triggered when Plone 4 (and plone.testing) is installed.
"""
+from plone.app.contenttypes.testing import PLONE_APP_CONTENTTYPES_FUNCTIONAL_TESTING
+from plone.testing import layered
+
import doctest
import unittest
-from plone.testing import layered
-from plone.app.contenttypes.testing import PLONE_APP_CONTENTTYPES_FUNCTIONAL_TESTING
optionflags = (doctest.ELLIPSIS | doctest.NORMALIZE_WHITESPACE)
normal_testfiles = [
diff --git a/plone/app/layout/viewlets/tests/test_history.py b/plone/app/layout/viewlets/tests/test_history.py
index 5d3cd196..caedc57a 100644
--- a/plone/app/layout/viewlets/tests/test_history.py
+++ b/plone/app/layout/viewlets/tests/test_history.py
@@ -1,12 +1,14 @@
-from plone.app.layout.viewlets.tests.base import ViewletsTestCase
-from plone.app.layout.viewlets.content import WorkflowHistoryViewlet
+# -*- coding: utf-8 -*-
from plone.app.layout.viewlets.content import ContentHistoryViewlet
+from plone.app.layout.viewlets.content import WorkflowHistoryViewlet
+from plone.app.layout.viewlets.tests.base import ViewletsTestCase
class TestWorkflowHistoryViewlet(ViewletsTestCase):
"""
Test the workflow history viewlet
"""
+
def afterSetUp(self):
# add document, perform transition, set history for non-existent
# member and also None (anonymous)
@@ -66,6 +68,7 @@ class TestContentHistoryViewlet(ViewletsTestCase):
"""
Test the workflow history viewlet
"""
+
def afterSetUp(self):
# add document, perform transition, set history for non-existent
# member and also None (anonymous)
@@ -96,7 +99,8 @@ def test_revisionHistory(self):
viewlet.update()
history = viewlet.revisionHistory()
self.assertTrue(
- 'http://nohost/plone/Members/test_user_1_/d1/@@history?one=1&two=0' in history[0]['diff_previous_url']
+ 'http://nohost/plone/Members/test_user_1_/d1/@@history?one=1&two=0' in history[
+ 0]['diff_previous_url']
)
# check diff link does not appear if content is not diffable
@@ -107,7 +111,8 @@ def test_revisionHistory(self):
self.assertFalse('diff_previous_url' in history[0])
def test_revertAbility(self):
- # check revert URL is generated only if the user has the appropriate permission
+ # check revert URL is generated only if the user has the appropriate
+ # permission
repo_tool = self.portal.portal_repository
request = self.app.REQUEST
context = getattr(self.folder, 'd1')
@@ -122,7 +127,8 @@ def test_revertAbility(self):
self.assertTrue(
'http://nohost/plone/Members/test_user_1_/d1/revertversion' in history[0]['revert_url']) # noqa
- self.portal.manage_permission('CMFEditions: Revert to previous versions', [], False)
+ self.portal.manage_permission(
+ 'CMFEditions: Revert to previous versions', [], False)
viewlet.update()
history = viewlet.revisionHistory()
diff --git a/plone/app/layout/viewlets/tests/test_social.py b/plone/app/layout/viewlets/tests/test_social.py
index d670854b..e93941a5 100644
--- a/plone/app/layout/viewlets/tests/test_social.py
+++ b/plone/app/layout/viewlets/tests/test_social.py
@@ -1,8 +1,8 @@
# -*- coding: utf-8 -*-
-from Products.CMFPlone.interfaces import ISocialMediaSchema
from plone.app.layout.viewlets.social import SocialTagsViewlet
from plone.app.layout.viewlets.tests.base import ViewletsTestCase
from plone.registry.interfaces import IRegistry
+from Products.CMFPlone.interfaces import ISocialMediaSchema
from zope.component import getUtility
diff --git a/plone/app/layout/viewlets/toolbar.py b/plone/app/layout/viewlets/toolbar.py
index 29c89b63..8634bd2f 100644
--- a/plone/app/layout/viewlets/toolbar.py
+++ b/plone/app/layout/viewlets/toolbar.py
@@ -1,11 +1,12 @@
+# -*- coding: utf-8 -*-
+from plone.app.layout.viewlets.common import PersonalBarViewlet
from plone.app.viewletmanager.manager import OrderedViewletManager
-from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile
-from zope.component import getMultiAdapter
from plone.memoize.instance import memoize
-from plone.app.layout.viewlets.common import PersonalBarViewlet
-from zope.component import getUtility
from plone.registry.interfaces import IRegistry
from Products.CMFPlone.interfaces.controlpanel import ISiteSchema
+from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile
+from zope.component import getMultiAdapter
+from zope.component import getUtility
class ToolbarViewletManager(OrderedViewletManager):
@@ -20,16 +21,21 @@ def render(self):
@property
@memoize
def portal_state(self):
- return getMultiAdapter((self.context, self.request), name='plone_portal_state')
+ return getMultiAdapter(
+ (self.context, self.request),
+ name='plone_portal_state'
+ )
def get_personal_bar(self):
- viewlet = PersonalBarViewlet(self.context, self.request, self.__parent__, self)
+ viewlet = PersonalBarViewlet(
+ self.context, self.request, self.__parent__, self)
viewlet.update()
return viewlet
def get_toolbar_logo(self):
registry = getUtility(IRegistry)
- settings = registry.forInterface(ISiteSchema, prefix='plone', check=False)
+ settings = registry.forInterface(
+ ISiteSchema, prefix='plone', check=False)
portal_url = self.portal_state.portal_url()
try:
logo = settings.toolbar_logo
diff --git a/setup.cfg b/setup.cfg
index fa859438..1d6003f4 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -2,3 +2,11 @@
ignore =
bootstrap.py
jenkins.cfg
+
+[isort]
+force_alphabetical_sort=True
+force_single_line=True
+lines_after_imports=2
+line_length=200
+not_skip=__init__.py
+