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

[WIP] Python 3 compatibility #70

Draft
wants to merge 7 commits into
base: 2.x
Choose a base branch
from
Draft
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
10 changes: 10 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@ Changelog
2.1.3 (unreleased)
------------------

- Python 3 compatibility.
[thet]

- Code cleanup:
- Remove bootstrap.py
- Format code according to Plone standards: black, isort.
Format zcml using zpretty.
Format xml using zpretty.
[thet]

- update to build on Plone 5.1 latest
[tkimnguyen]

Expand Down
2 changes: 1 addition & 1 deletion base.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ eggs = plone.app.workflowmanager
[code-analysis]
recipe = plone.recipe.codeanalysis
directory = ${buildout:directory}/src/plone/app/workflowmanager/
flake8-exclude = bootstrap.py,bootstrap-buildout.py,docs,*.egg.,omelette
flake8-exclude = docs,*.egg.,omelette
flake8-max-complexity = 15


Expand Down
127 changes: 0 additions & 127 deletions bootstrap.py

This file was deleted.

102 changes: 51 additions & 51 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,58 +1,58 @@
from setuptools import find_packages
from setuptools import setup

version = '2.1.3.dev0'

setup(name='plone.app.workflowmanager',
version=version,
description="A workflow manager for Plone",
long_description=(
open("README.rst").read() + "\n" +
open("CHANGES.rst").read()
),
# Get more strings from https://pypi.python.org/pypi?%3Aaction=list_classifiers
classifiers=[
"Framework :: Plone",
"Framework :: Plone :: 4.3",
"Framework :: Plone :: 5.0",
"Framework :: Plone :: 5.1",
"Intended Audience :: Customer Service",
"Intended Audience :: Developers",
"License :: OSI Approved :: GNU General Public License (GPL)",
"Operating System :: OS Independent",
"Programming Language :: Other Scripting Engines",
"Programming Language :: Python",
"Topic :: Internet :: WWW/HTTP :: Site Management",
"Topic :: Software Development :: Libraries :: Python Modules",
],
keywords='plone workflow manager gui',
author='Nathan Van Gheem',
author_email='[email protected]',
url='https://github.com/plone/plone.app.workflowmanager',
license='GPL',
packages=find_packages('src'),
package_dir={'': 'src'},
namespace_packages=['plone', 'plone.app'],
include_package_data=True,
zip_safe=False,
install_requires=[
'Plone',
'setuptools',
'plone.api',
'plone.app.jquery>=1.7',
'plone.app.jquerytools',
],
extras_require={
'test': [
'plone.app.testing',
'plone.app.jquerytools',
'plone.app.robotframework',
'interlude',
'unittest2',
]
},
entry_points="""
version = "2.1.3.dev0"

setup(
name="plone.app.workflowmanager",
version=version,
description="A workflow manager for Plone",
long_description=(open("README.rst").read() + "\n" + open("CHANGES.rst").read()),
# Get more strings from https://pypi.python.org/pypi?%3Aaction=list_classifiers
classifiers=[
"Framework :: Plone",
"Framework :: Plone :: 4.3",
"Framework :: Plone :: 5.0",
"Framework :: Plone :: 5.1",
"Framework :: Plone :: 5.2",
"Intended Audience :: Customer Service",
"Intended Audience :: Developers",
"License :: OSI Approved :: GNU General Public License (GPL)",
"Operating System :: OS Independent",
"Programming Language :: Other Scripting Engines",
"Programming Language :: Python",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Topic :: Internet :: WWW/HTTP :: Site Management",
"Topic :: Software Development :: Libraries :: Python Modules",
],
keywords="plone workflow manager gui",
author="Nathan Van Gheem",
author_email="[email protected]",
url="https://github.com/plone/plone.app.workflowmanager",
license="GPL",
packages=find_packages("src"),
package_dir={"": "src"},
namespace_packages=["plone", "plone.app"],
include_package_data=True,
zip_safe=False,
install_requires=[
"Plone",
"setuptools",
"plone.api",
],
extras_require={
"test": [
"plone.app.testing",
"plone.app.robotframework",
"interlude",
]
},
entry_points="""
[z3c.autoinclude.plugin]
target = plone
""",
)
)
3 changes: 2 additions & 1 deletion src/plone/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# See http://peak.telecommunity.com/DevCenter/setuptools#namespace-packages
try:
__import__('pkg_resources').declare_namespace(__name__)
__import__("pkg_resources").declare_namespace(__name__)
except ImportError:
from pkgutil import extend_path

__path__ = extend_path(__path__, __name__)
3 changes: 2 additions & 1 deletion src/plone/app/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# See http://peak.telecommunity.com/DevCenter/setuptools#namespace-packages
try:
__import__('pkg_resources').declare_namespace(__name__)
__import__("pkg_resources").declare_namespace(__name__)
except ImportError:
from pkgutil import extend_path

__path__ = extend_path(__path__, __name__)
5 changes: 3 additions & 2 deletions src/plone/app/workflowmanager/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#
from zope.i18nmessageid.message import MessageFactory
WMMessageFactory = MessageFactory('plone.app.workflowmanager')


WMMessageFactory = MessageFactory("plone.app.workflowmanager")
49 changes: 26 additions & 23 deletions src/plone/app/workflowmanager/actionmanager.py
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
from zope.component import queryUtility

from plone.memoize.instance import memoize
from plone.contentrules.engine.interfaces import IRuleStorage
from plone.contentrules.engine.interfaces import IRuleAssignmentManager
from plone.app.contentrules.conditions.wftransition import \
WorkflowTransitionCondition
from plone.app.contentrules.conditions.wftransition import WorkflowTransitionCondition
from plone.app.contentrules.rule import get_assignments
from plone.app.contentrules.rule import Rule
from plone.app.workflowmanager.utils import generateRuleName
from plone.app.workflowmanager.utils import generateRuleNameOld
from plone.contentrules.engine import utils
from plone.app.contentrules.rule import Rule, get_assignments
from plone.contentrules.engine.assignments import RuleAssignment
from plone.contentrules.engine.interfaces import IRuleAssignmentManager
from plone.contentrules.engine.interfaces import IRuleStorage
from plone.memoize.instance import memoize
from Products.CMFCore.interfaces._events import IActionSucceededEvent
from Products.CMFCore.utils import getToolByName
from plone.app.workflowmanager.utils import generateRuleName, generateRuleNameOld

from zope.component import queryUtility
from zope.i18nmessageid import MessageFactory


_ = MessageFactory(u"plone")


class RuleAdapter(object):

def __init__(self, rule, transition):
self.rule = rule
self.transition = transition

@property
@memoize
def portal(self):
return getToolByName(self.transition, 'portal_url').getPortalObject()
return getToolByName(self.transition, "portal_url").getPortalObject()

def activate(self):
"""
Expand All @@ -39,9 +39,10 @@ def activate(self):
self.rule.event = IActionSucceededEvent

assignable = IRuleAssignmentManager(self.portal)
path = '/'.join(self.portal.getPhysicalPath())
assignable[self.rule.__name__] = RuleAssignment(self.rule.id,
enabled=True, bubbles=True)
path = "/".join(self.portal.getPhysicalPath())
assignable[self.rule.__name__] = RuleAssignment(
self.rule.id, enabled=True, bubbles=True
)
assignments = get_assignments(self.rule)
if not path in assignments:
assignments.insert(path)
Expand All @@ -57,10 +58,11 @@ def action_index(self, action):
return self.rule.actions.index(action)

def action_url(self, action):
return '%s/%s/++action++%d/edit' % (
return "%s/%s/++action++%d/edit" % (
self.portal.absolute_url(),
self.rule.id,
self.action_index(action), )
self.action_index(action),
)

def delete_action(self, index):
self.rule.actions.remove(self.rule.actions[index])
Expand All @@ -71,7 +73,6 @@ def actions(self):


class ActionManager(object):

def get_rule(self, transition):
rulename = generateRuleName(transition)
rulename_old = generateRuleNameOld(transition)
Expand All @@ -87,11 +88,13 @@ def create(self, transition):
rule_id = generateRuleName(transition)
r = Rule()
r.title = _(u"%s transition content rule") % transition.id
r.description = _(u"This content rule was automatically created "
u"the workflow manager to create actions on "
u"workflow events. If you want the behavior to "
u"work as expected, do not modify this out of "
u"the workflow manager.")
r.description = _(
u"This content rule was automatically created "
u"the workflow manager to create actions on "
u"workflow events. If you want the behavior to "
u"work as expected, do not modify this out of "
u"the workflow manager."
)
self.storage[rule_id] = r
rule = RuleAdapter(r, transition)
rule.activate()
Expand Down
Loading