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

Plone base overhaul #71

Merged
merged 6 commits into from
May 3, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 2 additions & 2 deletions plone/app/contentrules/actions/copy.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
from plone.app.contentrules.actions import ActionEditForm
from plone.app.contentrules.browser.formhelper import ContentRuleFormWrapper
from plone.app.vocabularies.catalog import CatalogSource
from plone.base.utils import pretty_title_or_id
from plone.contentrules.rule.interfaces import IExecutable
from plone.contentrules.rule.interfaces import IRuleElementData
from Products.CMFCore.utils import getToolByName
from Products.CMFPlone import utils
from Products.statusmessages.interfaces import IStatusMessage
from ZODB.POSException import ConflictError
from zope import schema
Expand Down Expand Up @@ -112,7 +112,7 @@ def __call__(self):
def error(self, obj, error):
request = getattr(self.context, "REQUEST", None)
if request is not None:
title = utils.pretty_title_or_id(obj, obj)
title = pretty_title_or_id(obj, obj)
message = _(
"Unable to copy ${name} as part of content rule "
"'copy' action: ${error}",
Expand Down
4 changes: 2 additions & 2 deletions plone/app/contentrules/actions/delete.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
from OFS.SimpleItem import SimpleItem
from plone.app.contentrules import PloneMessageFactory as _
from plone.app.contentrules.browser.formhelper import NullAddForm
from plone.base.utils import pretty_title_or_id
from plone.contentrules.rule.interfaces import IExecutable
from plone.contentrules.rule.interfaces import IRuleElementData
from Products.CMFPlone import utils
from Products.statusmessages.interfaces import IStatusMessage
from ZODB.POSException import ConflictError
from zope.component import adapter
Expand Down Expand Up @@ -56,7 +56,7 @@ def __call__(self):
def error(self, obj, error):
request = getattr(self.context, "REQUEST", None)
if request is not None:
title = utils.pretty_title_or_id(obj, obj)
title = pretty_title_or_id(obj, obj)
message = _(
"Unable to remove ${name} as part of content rule 'delete' action: ${error}", # noqa
mapping={"name": title, "error": error},
Expand Down
2 changes: 1 addition & 1 deletion plone/app/contentrules/actions/mail.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
from plone.app.contentrules.actions import ActionAddForm
from plone.app.contentrules.actions import ActionEditForm
from plone.app.contentrules.browser.formhelper import ContentRuleFormWrapper
from plone.base.interfaces.controlpanel import IMailSchema
from plone.contentrules.rule.interfaces import IExecutable
from plone.contentrules.rule.interfaces import IRuleElementData
from plone.registry.interfaces import IRegistry
from plone.stringinterp.interfaces import IStringInterpolator
from Products.CMFCore.utils import getToolByName
from Products.CMFPlone.interfaces.controlpanel import IMailSchema
from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile
from Products.MailHost.MailHost import MailHostError
from Products.statusmessages.interfaces import IStatusMessage
Expand Down
4 changes: 2 additions & 2 deletions plone/app/contentrules/actions/move.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
from plone.app.contentrules.actions import ActionEditForm
from plone.app.contentrules.browser.formhelper import ContentRuleFormWrapper
from plone.app.vocabularies.catalog import CatalogSource
from plone.base.utils import pretty_title_or_id
from plone.contentrules.rule.interfaces import IExecutable
from plone.contentrules.rule.interfaces import IRuleElementData
from Products.CMFCore.utils import getToolByName
from Products.CMFPlone import utils
from Products.statusmessages.interfaces import IStatusMessage
from ZODB.POSException import ConflictError
from zope import schema
Expand Down Expand Up @@ -131,7 +131,7 @@ def __call__(self):
def error(self, obj, error):
request = getattr(self.context, "REQUEST", None)
if request is not None:
title = utils.pretty_title_or_id(obj, obj)
title = pretty_title_or_id(obj, obj)
message = _(
"Unable to move ${name} as part of content rule "
"'move' action: ${error}",
Expand Down
7 changes: 4 additions & 3 deletions plone/app/contentrules/actions/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
from plone.app.contentrules.actions import ActionAddForm
from plone.app.contentrules.actions import ActionEditForm
from plone.app.contentrules.browser.formhelper import ContentRuleFormWrapper
from plone.base.utils import pretty_title_or_id
from plone.base.utils import safe_text
from plone.contentrules.rule.interfaces import IExecutable
from plone.contentrules.rule.interfaces import IRuleElementData
from Products.CMFCore.utils import getToolByName
from Products.CMFPlone import utils
from Products.statusmessages.interfaces import IStatusMessage
from ZODB.POSException import ConflictError
from zope import schema
Expand Down Expand Up @@ -74,8 +75,8 @@ def __call__(self):
def error(self, obj, error):
request = getattr(self.context, "REQUEST", None)
if request is not None:
title = utils.safe_unicode(utils.pretty_title_or_id(obj, obj))
error = utils.safe_unicode(error)
title = safe_text(pretty_title_or_id(obj, obj))
error = safe_text(error)
message = _(
"Unable to change state of ${name} as part of content rule 'workflow' action: ${error}", # noqa
mapping={"name": title, "error": error},
Expand Down
10 changes: 5 additions & 5 deletions plone/app/contentrules/browser/configure.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -94,39 +94,39 @@
/>

<browser:page
for="Products.CMFPlone.interfaces.siteroot.IPloneSiteRoot"
for="plone.base.interfaces.siteroot.IPloneSiteRoot"
name="contentrule-enable"
class=".controlpanel.ContentRulesControlPanel"
attribute="enable_rule"
permission="plone.app.contentrules.ManageContentRules"
/>

<browser:page
for="Products.CMFPlone.interfaces.siteroot.IPloneSiteRoot"
for="plone.base.interfaces.siteroot.IPloneSiteRoot"
name="contentrule-disable"
class=".controlpanel.ContentRulesControlPanel"
attribute="disable_rule"
permission="plone.app.contentrules.ManageContentRules"
/>

<browser:page
for="Products.CMFPlone.interfaces.siteroot.IPloneSiteRoot"
for="plone.base.interfaces.siteroot.IPloneSiteRoot"
name="contentrule-delete"
class=".controlpanel.ContentRulesControlPanel"
attribute="delete_rule"
permission="plone.app.contentrules.ManageContentRules"
/>

<browser:page
for="Products.CMFPlone.interfaces.siteroot.IPloneSiteRoot"
for="plone.base.interfaces.siteroot.IPloneSiteRoot"
name="contentrule-globally-enable"
class=".controlpanel.ContentRulesControlPanel"
attribute="globally_enable"
permission="plone.app.contentrules.ManageContentRules"
/>

<browser:page
for="Products.CMFPlone.interfaces.siteroot.IPloneSiteRoot"
for="plone.base.interfaces.siteroot.IPloneSiteRoot"
name="contentrule-globally-disable"
class=".controlpanel.ContentRulesControlPanel"
attribute="globally_disable"
Expand Down
2 changes: 1 addition & 1 deletion plone/app/contentrules/browser/rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
from plone.app.contentrules.browser.formhelper import ContentRuleFormWrapper
from plone.app.contentrules.browser.formhelper import EditForm
from plone.app.contentrules.rule import Rule
from plone.base.utils import base_hasattr
from plone.contentrules.rule.interfaces import IRuleConfiguration
from Products.CMFPlone.utils import base_hasattr
from z3c.form.form import applyChanges
from zope.component import getMultiAdapter

Expand Down
10 changes: 0 additions & 10 deletions plone/app/contentrules/conditions/fileextension.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,6 @@
from zope.interface import Interface


try:
from Products.ATContentTypes.interfaces import IFileContent
except ImportError:
IFileContent = None


class IFileExtensionCondition(Interface):
"""Interface for the configurable aspects of a portal type condition.

Expand Down Expand Up @@ -66,10 +60,6 @@ def __call__(self):
if IFile.providedBy(obj):
base_unit = getattr(obj, "file", None)
name = getattr(base_unit, "filename", None)
elif IFileContent is None:
return False
elif not IFileContent.providedBy(obj):
return False
else:
Copy link
Member

Choose a reason for hiding this comment

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

This else was only executed if IFileContent.providedBy(obj). This can no longer be true, so this code branch can be removed.

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmm, no, its now executed if not IFile.providedBy(obj)

base_unit = obj.getFile()
get_filename = getattr(base_unit, "getFilename", None)
Expand Down
12 changes: 0 additions & 12 deletions plone/app/contentrules/configure.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,6 @@
<implements interface="plone.contentrules.engine.interfaces.IRuleAssignable" />
</class>

<configure zcml:condition="installed Products.ATContentTypes">

<class class="Products.ATContentTypes.content.folder.ATFolder">
<implements interface="plone.contentrules.engine.interfaces.IRuleAssignable" />
</class>

<class class="Products.ATContentTypes.content.folder.ATBTreeFolder">
<implements interface="plone.contentrules.engine.interfaces.IRuleAssignable" />
</class>

</configure>

<!-- Let rules be annotatable - used to keep track of rule-to-assignment mappings -->

<class class="plone.app.contentrules.rule.Rule">
Expand Down
12 changes: 2 additions & 10 deletions plone/app/contentrules/tests/test_action_mail.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
from Acquisition import aq_base
from email import message_from_bytes
from plone.app.contentrules.actions.mail import MailAction
from plone.app.contentrules.actions.mail import MailAddFormView
from plone.app.contentrules.actions.mail import MailEditFormView
from plone.app.contentrules.rule import Rule
from plone.app.contentrules.tests.base import ContentRulesTestCase
from plone.app.testing import setRoles
from plone.app.testing import TEST_USER_ID
from plone.base.interfaces.controlpanel import IMailSchema
from plone.contentrules.engine.interfaces import IRuleStorage
from plone.contentrules.rule.interfaces import IExecutable
from plone.contentrules.rule.interfaces import IRuleAction
from plone.registry.interfaces import IRegistry
from Products.CMFPlone.interfaces.controlpanel import IMailSchema
from Products.CMFPlone.tests.utils import MockMailHost
from Products.MailHost.interfaces import IMailHost
from zope.component import getMultiAdapter
from zope.component import getSiteManager
Expand All @@ -22,14 +22,6 @@
import unittest


try:
# Python 3
from email import message_from_bytes
except ImportError:
# Python 2
from email import message_from_string as message_from_bytes


@implementer(IObjectEvent)
class DummyEvent:
def __init__(self, object):
Expand Down
18 changes: 0 additions & 18 deletions plone/app/contentrules/tests/test_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,21 +36,3 @@ def test_call_uuidaware(self):
self.assertTrue(to_execute)
to_execute = self.rulefilter(self.uuidaware, self.rule, self.event)
self.assertTrue(not to_execute)

def test_delayed_events(self):
# many events can be delayed
# But this was only true for Archetypes content.
# The tests no use dexterity so we skip it:
return

self.portal.invokeFactory("Folder", "folder2")
event1 = dummy.DummyEvent(self.folder)
event2 = dummy.DummyEvent(self.portal.folder2)
from plone.app.contentrules.handlers import _status

_status.delayed_events = {}
handlers.added(event1)
handlers.added(event2)
from plone.app.contentrules.handlers import _status

self.assertEqual(len(_status.delayed_events), 2)