diff --git a/last_commit.txt b/last_commit.txt index 59e41b596d..a7f7016e04 100644 --- a/last_commit.txt +++ b/last_commit.txt @@ -1,1425 +1,28 @@ -Repository: plone.app.iterate +Repository: mockup Branch: refs/heads/master -Date: 2016-12-22T01:59:09+01:00 -Author: Jens W. Klein (jensens) -Commit: https://github.com/plone/plone.app.iterate/commit/5b89c4c7d0d55cc536a23b33f35fc62a62ce0832 - -do not hard depend on at anymore - -Files changed: -A plone/app/iterate/at.zcml -M CHANGES.rst -M plone/app/iterate/configure.zcml -M plone/app/iterate/copier.py -M plone/app/iterate/dexterity/copier.py -M plone/app/iterate/dexterity/relation.py -M plone/app/iterate/dexterity/utils.py -M plone/app/iterate/interfaces.py -M plone/app/iterate/policy.py -M plone/app/iterate/relation.py -M plone/app/iterate/testing.py -M setup.py - -diff --git a/CHANGES.rst b/CHANGES.rst -index 42f1217..f28d97d 100644 ---- a/CHANGES.rst -+++ b/CHANGES.rst -@@ -1,7 +1,7 @@ - Changelog - ========= - --3.2.4 (unreleased) -+3.3.0 (unreleased) - ------------------ - - Breaking changes: -@@ -10,7 +10,9 @@ Breaking changes: - - New features: - --- *add item here* -+- Do not depend on Products.Archetypes anymore. -+ If Archetypes is present it still registers the adapters. -+ [jensens] - - Bug fixes: - -diff --git a/plone/app/iterate/at.zcml b/plone/app/iterate/at.zcml -new file mode 100644 -index 0000000..e6b938f ---- /dev/null -+++ b/plone/app/iterate/at.zcml -@@ -0,0 +1,15 @@ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -\ No newline at end of file -diff --git a/plone/app/iterate/configure.zcml b/plone/app/iterate/configure.zcml -index 5b5f395..7d15fdc 100644 ---- a/plone/app/iterate/configure.zcml -+++ b/plone/app/iterate/configure.zcml -@@ -65,15 +65,7 @@ - factory=".profiles.HiddenProfiles" - /> - -- -- -- -- -- -- -- - -- - - - - - -+ - - -diff --git a/plone/app/iterate/copier.py b/plone/app/iterate/copier.py -index 70e0fa3..ef6dc0b 100644 ---- a/plone/app/iterate/copier.py -+++ b/plone/app/iterate/copier.py -@@ -22,7 +22,7 @@ - ################################################################## - - """ --$Id: copier.py 1824 2007-02-08 17:59:41Z hazmat $ -+Archtypes specific copier, dexterity folder has its own! - """ - - from Acquisition import aq_base -diff --git a/plone/app/iterate/dexterity/copier.py b/plone/app/iterate/dexterity/copier.py -index 7e6c82b..19bec8a 100644 ---- a/plone/app/iterate/dexterity/copier.py -+++ b/plone/app/iterate/dexterity/copier.py -@@ -16,15 +16,10 @@ - from zope.annotation.interfaces import IAnnotations - from zope.event import notify - from zope.interface import implementer -+from zope.intid.interfaces import IIntIds - from zope.schema import getFieldsInOrder - - --try: -- from zope.intid.interfaces import IIntIds --except ImportError: -- from zope.app.intid.interfaces import IIntIds -- -- - @implementer(interfaces.IObjectCopier) - class ContentCopier(copier.ContentCopier): - -diff --git a/plone/app/iterate/dexterity/relation.py b/plone/app/iterate/dexterity/relation.py -index fa3b054..8c2eca1 100644 ---- a/plone/app/iterate/dexterity/relation.py -+++ b/plone/app/iterate/dexterity/relation.py -@@ -5,12 +5,7 @@ - from zope.annotation.interfaces import IAttributeAnnotatable - from zope.component import getUtility - from zope.interface import implementer -- -- --try: -- from zope.intid.interfaces import IIntIds --except ImportError: -- from zope.app.intid.interfaces import IIntIds -+from zope.intid.interfaces import IIntIds - - - @implementer(IStagingRelationValue, IAttributeAnnotatable) -diff --git a/plone/app/iterate/dexterity/utils.py b/plone/app/iterate/dexterity/utils.py -index ad7bada..2ec7357 100644 ---- a/plone/app/iterate/dexterity/utils.py -+++ b/plone/app/iterate/dexterity/utils.py -@@ -4,12 +4,7 @@ - from plone.app.iterate.dexterity import ITERATE_RELATION_NAME - from zc.relation.interfaces import ICatalog - from zope import component -- -- --try: -- from zope.intid.interfaces import IIntIds --except ImportError: -- from zope.app.intid.interfaces import IIntIds -+from zope.intid.interfaces import IIntIds - - - def get_relations(context): -diff --git a/plone/app/iterate/interfaces.py b/plone/app/iterate/interfaces.py -index 1656454..3262538 100644 ---- a/plone/app/iterate/interfaces.py -+++ b/plone/app/iterate/interfaces.py -@@ -27,12 +27,23 @@ - from plone.app.iterate import PloneMessageFactory as _ - from plone.locking.interfaces import LockType - from plone.locking.interfaces import MAX_TIMEOUT --from Products.Archetypes.interfaces import IReference - from zope import schema - from zope.component.interfaces import IObjectEvent - from zope.interface import Attribute - from zope.interface import Interface - -+import pkg_resources -+ -+ -+try: -+ pkg_resources.get_distribution('Products.Archetypes') -+except pkg_resources.DistributionNotFound: -+ -+ class IReference(Interface): -+ pass -+else: -+ from Products.Archetypes.interfaces import IReference -+ - - ################################ - # Marker interface -diff --git a/plone/app/iterate/policy.py b/plone/app/iterate/policy.py -index f7109f0..fc34ebd 100644 ---- a/plone/app/iterate/policy.py -+++ b/plone/app/iterate/policy.py -@@ -21,7 +21,7 @@ - # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - ################################################################## - """ --A Default Checkin Checkout Policy For Content -+Archetypes Checkin Checkout Policy For Content - - """ - -diff --git a/plone/app/iterate/relation.py b/plone/app/iterate/relation.py -index bc96439..bcfa0b1 100644 ---- a/plone/app/iterate/relation.py -+++ b/plone/app/iterate/relation.py -@@ -21,7 +21,7 @@ - # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - ################################################################## - """ --$Id: relation.py 1392 2006-06-20 01:02:17Z hazmat $ -+Archetypes speicifc implementation for relation handling - """ - - from interfaces import ICheckinCheckoutReference -diff --git a/plone/app/iterate/testing.py b/plone/app/iterate/testing.py -index cd0484b..0cefdbf 100644 ---- a/plone/app/iterate/testing.py -+++ b/plone/app/iterate/testing.py -@@ -8,6 +8,16 @@ - from plone.app.testing.layers import IntegrationTesting - from plone.testing import z2 - -+import pkg_resources -+ -+ -+try: -+ pkg_resources.get_distribution('Products.Archtypes') -+except pkg_resources.DistributionNotFound: -+ HAS_AT = False -+else: -+ HAS_AT = True -+ - - ADMIN = { - 'id': 'admin', -@@ -42,14 +52,15 @@ class PloneAppIterateLayer(PloneSandboxLayer): - - def setUpZope(self, app, configurationContext): - """Setup Zope with Addons.""" -- import Products.ATContentTypes -- self.loadZCML(package=Products.ATContentTypes) -- z2.installProduct(app, 'Products.ATContentTypes') -+ if HAS_AT: -+ import Products.ATContentTypes -+ self.loadZCML(package=Products.ATContentTypes) -+ z2.installProduct(app, 'Products.ATContentTypes') - -- z2.installProduct(app, 'Products.Archetypes') -- z2.installProduct(app, 'Products.ATContentTypes') -- z2.installProduct(app, 'plone.app.blob') -- z2.installProduct(app, 'plone.app.collection') -+ z2.installProduct(app, 'Products.Archetypes') -+ z2.installProduct(app, 'Products.ATContentTypes') -+ z2.installProduct(app, 'plone.app.blob') -+ z2.installProduct(app, 'plone.app.collection') - - import plone.app.iterate - self.loadZCML(package=plone.app.iterate) -@@ -59,8 +70,9 @@ def setUpPloneSite(self, portal): - # restore default workflow - applyProfile(portal, 'Products.CMFPlone:testfixture') - -- # add default content -- applyProfile(portal, 'Products.ATContentTypes:content') -+ if HAS_AT: -+ # add default content -+ applyProfile(portal, 'Products.ATContentTypes:content') - - applyProfile(portal, 'plone.app.iterate:default') - applyProfile(portal, 'plone.app.iterate:test') -diff --git a/setup.py b/setup.py -index fc8f810..7b27d68 100644 ---- a/setup.py -+++ b/setup.py -@@ -57,13 +57,16 @@ - 'zope.lifecycleevent', - 'zope.schema', - 'zope.viewlet', -- 'Zope2', - ], - extras_require={ -+ 'archetypes': [ -+ 'Products.Archetypes', -+ ], - 'test': [ - 'plone.app.testing', - 'plone.app.contenttypes', -- 'plone.app.robotframework' -+ 'plone.app.robotframework', -+ 'Products.Archetypes', - ] - }, - entry_points=""" - - -Repository: plone.app.iterate - - -Branch: refs/heads/master -Date: 2016-12-22T15:57:11+01:00 -Author: Jens W. Klein (jensens) -Commit: https://github.com/plone/plone.app.iterate/commit/79f0064502db564710da42095cc80f8ed313cc11 - -remove unittest2 - -Files changed: -A plone/app/iterate/base.py -M CHANGES.rst -M plone/app/iterate/configure.zcml -M plone/app/iterate/dexterity/policy.py -M plone/app/iterate/policy.py -M plone/app/iterate/profiles/test/portal_placeful_workflow/working-copy.xml -M plone/app/iterate/testing.py -M plone/app/iterate/tests/test_interfaces.py -M plone/app/iterate/tests/test_iterate.py - -diff --git a/CHANGES.rst b/CHANGES.rst -index f28d97d..5d4bda7 100644 ---- a/CHANGES.rst -+++ b/CHANGES.rst -@@ -16,6 +16,9 @@ New features: - - Bug fixes: - -+- Do not use unittest2 anymore. -+ [jensens] -+ - - Cleanup: isort, zca decorators, etc. - [jensens] - -diff --git a/plone/app/iterate/base.py b/plone/app/iterate/base.py -new file mode 100644 -index 0000000..c2e895b ---- /dev/null -+++ b/plone/app/iterate/base.py -@@ -0,0 +1,99 @@ -+# -*- coding: utf-8 -*- -+################################################################## -+# -+# (C) Copyright 2006-2007 ObjectRealms, LLC -+# (C) Copyright 2007-2017 Plone Foundation -+# All Rights Reserved -+# -+# This file is part of iterate. -+# -+# iterate is free software; you can redistribute it and/or modify -+# it under the terms of the GNU General Public License as published by -+# the Free Software Foundation; either version 2 of the License, or -+# (at your option) any later version. -+# -+# iterate is distributed in the hope that it will be useful, -+# but WITHOUT ANY WARRANTY; without even the implied warranty of -+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+# GNU General Public License for more details. -+# -+# You should have received a copy of the GNU General Public License -+# along with CMFDeployment; if not, write to the Free Software -+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -+################################################################## -+""" -+Base Checkin Checkout Policy For Content -+ -+""" -+ -+from Acquisition import aq_inner -+from Acquisition import aq_parent -+from plone.app.iterate.event import BeforeCheckoutEvent -+from plone.app.iterate.event import CancelCheckoutEvent -+from plone.app.iterate.event import CheckoutEvent -+from plone.app.iterate.interfaces import ICheckinCheckoutPolicy -+from plone.app.iterate.interfaces import IObjectCopier -+from plone.app.iterate.util import get_storage -+from zope.component import queryAdapter -+from zope.event import notify -+from zope.interface import implementer -+ -+ -+@implementer(ICheckinCheckoutPolicy) -+class CheckinCheckoutBasePolicyAdapter(object): -+ """Base Checkin Checkout Policy For Content -+ -+ - on checkout context is the baseline -+ - on checkin context is the working copy. -+ -+ """ -+ -+ # used when creating baseline version for first time -+ default_base_message = 'Created Baseline' -+ -+ def __init__(self, context): -+ self.context = context -+ -+ def checkin(self, checkin_message): -+ raise NotImplemented() -+ -+ def checkout(self, container): -+ # see interface -+ notify(BeforeCheckoutEvent(self.context)) -+ -+ # use the object copier to checkout the content to the container -+ copier = queryAdapter(self.context, IObjectCopier) -+ working_copy, relation = copier.copyTo(container) -+ -+ # publish the event for any subscribers -+ notify(CheckoutEvent(self.context, working_copy, relation)) -+ -+ # finally return the working copy -+ return working_copy -+ -+ def cancelCheckout(self): -+ # see interface -+ -+ # get the baseline -+ baseline = self._getBaseline() -+ -+ # publish an event -+ notify(CancelCheckoutEvent(self.context, baseline)) -+ -+ # delete the working copy -+ wc_container = aq_parent(aq_inner(self.context)) -+ wc_container.manage_delObjects([self.context.getId()]) -+ -+ return baseline -+ -+ ################################# -+ # Checkin Support Methods -+ -+ def getBaseline(self): -+ raise NotImplemented() -+ -+ def getWorkingCopy(self): -+ raise NotImplemented() -+ -+ def getProperties(self, obj, default=None): -+ return get_storage(obj, default=default) -diff --git a/plone/app/iterate/configure.zcml b/plone/app/iterate/configure.zcml -index 7d15fdc..39a2f62 100644 ---- a/plone/app/iterate/configure.zcml -+++ b/plone/app/iterate/configure.zcml -@@ -96,6 +96,6 @@ - /> - - -- -+ - - -diff --git a/plone/app/iterate/dexterity/policy.py b/plone/app/iterate/dexterity/policy.py -index a7496fc..14d1ea4 100644 ---- a/plone/app/iterate/dexterity/policy.py -+++ b/plone/app/iterate/dexterity/policy.py -@@ -1,63 +1,57 @@ - # -*- coding: utf-8 -*- --from plone.app import iterate -+from plone.app.iterate.base import CheckinCheckoutBasePolicyAdapter -+from plone.app.iterate.dexterity.interfaces import IDexterityIterateAware - from plone.app.iterate.dexterity.utils import get_baseline - from plone.app.iterate.dexterity.utils import get_checkout_relation - from plone.app.iterate.dexterity.utils import get_relations - from plone.app.iterate.dexterity.utils import get_working_copy -+from plone.app.iterate.event import AfterCheckinEvent -+from plone.app.iterate.event import CheckinEvent -+from plone.app.iterate.interfaces import CheckinException -+from plone.app.iterate.interfaces import IObjectCopier - from plone.app.iterate.util import get_storage --from zope import component -+from zope.component import adapter -+from zope.component import queryAdapter - from zope.event import notify --from zope.interface import implementer - - --@implementer(iterate.interfaces.ICheckinCheckoutPolicy) --class CheckinCheckoutPolicyAdapter( -- iterate.policy.CheckinCheckoutPolicyAdapter --): -+@adapter(IDexterityIterateAware) -+class CheckinCheckoutPolicyAdapter(CheckinCheckoutBasePolicyAdapter): - """ - Dexterity Checkin Checkout Policy - """ - -+ def checkin(self, checkin_message): -+ # get the baseline for this working copy, raise if not found -+ baseline = self._getBaseline() -+ # get a hold of the relation object -+ relation = self._get_relation_to_baseline() -+ # publish the event for subscribers, early because contexts are about -+ # to be manipulated -+ notify(CheckinEvent(self.context, baseline, relation, checkin_message)) -+ # merge the object back to the baseline with a copier -+ copier = queryAdapter(self.context, IObjectCopier) -+ new_baseline = copier.merge() -+ # don't need to unlock the lock disappears with old baseline deletion -+ notify(AfterCheckinEvent(new_baseline, checkin_message)) -+ return new_baseline -+ - def _get_relation_to_baseline(self): - # do we have a baseline in our relations? - relations = get_relations(self.context) -- - if relations and not len(relations) == 1: -- raise iterate.interfaces.CheckinException( -- 'Baseline count mismatch') -- -+ raise CheckinException('Baseline count mismatch') - if not relations or not relations[0]: -- raise iterate.interfaces.CheckinException( -- 'Baseline has disappeared') -+ raise CheckinException('Baseline has disappeared') - - return relations[0] - - def _getBaseline(self): - baseline = get_baseline(self.context) - if not baseline: -- raise iterate.interfaces.CheckinException( -- 'Baseline has disappeared') -+ raise CheckinException('Baseline has disappeared') - return baseline - -- def checkin(self, checkin_message): -- # get the baseline for this working copy, raise if not found -- baseline = self._getBaseline() -- # get a hold of the relation object -- relation = self._get_relation_to_baseline() -- # publish the event for subscribers, early because contexts are about -- # to be manipulated -- notify(iterate.event.CheckinEvent(self.context, -- baseline, -- relation, -- checkin_message)) -- # merge the object back to the baseline with a copier -- copier = component.queryAdapter(self.context, -- iterate.interfaces.IObjectCopier) -- new_baseline = copier.merge() -- # don't need to unlock the lock disappears with old baseline deletion -- notify(iterate.event.AfterCheckinEvent(new_baseline, checkin_message)) -- return new_baseline -- - def getBaseline(self): - return get_baseline(self.context) - -diff --git a/plone/app/iterate/policy.py b/plone/app/iterate/policy.py -index fc34ebd..ac0fa4e 100644 ---- a/plone/app/iterate/policy.py -+++ b/plone/app/iterate/policy.py -@@ -24,55 +24,28 @@ - Archetypes Checkin Checkout Policy For Content - - """ -- --from Acquisition import aq_inner --from Acquisition import aq_parent -+from plone.app.iterate.base import CheckinCheckoutBasePolicyAdapter -+from plone.app.iterate.event import AfterCheckinEvent -+from plone.app.iterate.event import CheckinEvent -+from plone.app.iterate.interfaces import CheckinException -+from plone.app.iterate.interfaces import IIterateAware -+from plone.app.iterate.interfaces import IObjectCopier -+from plone.app.iterate.relation import WorkingCopyRelation - from plone.app.iterate.util import get_storage - from Products.Archetypes.interfaces import IReferenceable --from relation import WorkingCopyRelation --from zope import component -+from zope.component import adapter -+from zope.component import queryAdapter - from zope.event import notify --from zope.interface import implementer -- --import event --import interfaces -- -- --@implementer(interfaces.ICheckinCheckoutPolicy) --@component.adapter(interfaces.IIterateAware) --class CheckinCheckoutPolicyAdapter(object): -- """ -- Default Checkin Checkout Policy For Content -- -- on checkout context is the baseline - -- on checkin context is the working copy. - -- This default Policy works with Archetypes. -+@adapter(IIterateAware) -+class CheckinCheckoutPolicyAdapter(CheckinCheckoutBasePolicyAdapter): -+ """Checkin Checkout Policy For Archetypes Content - -- dexterity folder has dexterity compatible one -+ - on checkout context is the baseline -+ - on checkin context is the working copy. - """ - -- # used when creating baseline version for first time -- default_base_message = 'Created Baseline' -- -- def __init__(self, context): -- self.context = context -- -- def checkout(self, container): -- # see interface -- notify(event.BeforeCheckoutEvent(self.context)) -- -- # use the object copier to checkout the content to the container -- copier = component.queryAdapter(self.context, interfaces.IObjectCopier) -- working_copy, relation = copier.copyTo(container) -- -- # publish the event for any subscribers -- notify(event.CheckoutEvent(self.context, working_copy, relation)) -- -- # finally return the working copy -- return working_copy -- - def checkin(self, checkin_message): - # see interface - -@@ -81,40 +54,25 @@ def checkin(self, checkin_message): - - # get a hold of the relation object - wc_ref = self.context.getReferenceImpl( -- WorkingCopyRelation.relationship)[0] -+ WorkingCopyRelation.relationship -+ )[0] - - # publish the event for subscribers, early because contexts are about - # to be manipulated -- notify(event.CheckinEvent(self.context, -- baseline, wc_ref, checkin_message)) -+ notify(CheckinEvent(self.context, baseline, wc_ref, checkin_message)) - - # merge the object back to the baseline with a copier - - # XXX by gotcha - # bug we should or use a getAdapter call or test if copier is None -- copier = component.queryAdapter(self.context, interfaces.IObjectCopier) -+ copier = queryAdapter(self.context, IObjectCopier) - new_baseline = copier.merge() - - # don't need to unlock the lock disappears with old baseline deletion -- notify(event.AfterCheckinEvent(new_baseline, checkin_message)) -+ notify(AfterCheckinEvent(new_baseline, checkin_message)) - - return new_baseline - -- def cancelCheckout(self): -- # see interface -- -- # get the baseline -- baseline = self._getBaseline() -- -- # publish an event -- notify(event.CancelCheckoutEvent(self.context, baseline)) -- -- # delete the working copy -- wc_container = aq_parent(aq_inner(self.context)) -- wc_container.manage_delObjects([self.context.getId()]) -- -- return baseline -- - ################################# - # Checkin Support Methods - -@@ -123,10 +81,10 @@ def _getBaseline(self): - refs = self.context.getReferences(WorkingCopyRelation.relationship) - - if not len(refs) == 1: -- raise interfaces.CheckinException('Baseline count mismatch') -+ raise CheckinException('Baseline count mismatch') - - if not refs or refs[0] is None: -- raise interfaces.CheckinException('Baseline has disappeared') -+ raise CheckinException('Baseline has disappeared') - - baseline = refs[0] - return baseline -diff --git a/plone/app/iterate/profiles/test/portal_placeful_workflow/working-copy.xml b/plone/app/iterate/profiles/test/portal_placeful_workflow/working-copy.xml -index 938d3a3..a999931 100644 ---- a/plone/app/iterate/profiles/test/portal_placeful_workflow/working-copy.xml -+++ b/plone/app/iterate/profiles/test/portal_placeful_workflow/working-copy.xml -@@ -5,6 +5,6 @@ - - - -- -+ - - -diff --git a/plone/app/iterate/testing.py b/plone/app/iterate/testing.py -index 0cefdbf..95b9136 100644 ---- a/plone/app/iterate/testing.py -+++ b/plone/app/iterate/testing.py -@@ -12,7 +12,7 @@ - - - try: -- pkg_resources.get_distribution('Products.Archtypes') -+ pkg_resources.get_distribution('Products.Archetypes') - except pkg_resources.DistributionNotFound: - HAS_AT = False - else: -@@ -73,7 +73,6 @@ def setUpPloneSite(self, portal): - if HAS_AT: - # add default content - applyProfile(portal, 'Products.ATContentTypes:content') -- - applyProfile(portal, 'plone.app.iterate:default') - applyProfile(portal, 'plone.app.iterate:test') - -diff --git a/plone/app/iterate/tests/test_interfaces.py b/plone/app/iterate/tests/test_interfaces.py -index 1b7378c..12b99ca 100644 ---- a/plone/app/iterate/tests/test_interfaces.py -+++ b/plone/app/iterate/tests/test_interfaces.py -@@ -10,7 +10,7 @@ - from plone.app.testing import TEST_USER_ID - from plone.app.testing import TEST_USER_NAME - from plone.dexterity.utils import createContentInContainer --from unittest2 import TestCase -+from unittest import TestCase - - - class TestObjectsProvideCorrectInterfaces(TestCase): -diff --git a/plone/app/iterate/tests/test_iterate.py b/plone/app/iterate/tests/test_iterate.py -index f31539c..0b9dde3 100644 ---- a/plone/app/iterate/tests/test_iterate.py -+++ b/plone/app/iterate/tests/test_iterate.py -@@ -34,7 +34,7 @@ - from plone.app.testing import TEST_USER_NAME - from Products.CMFCore.utils import getToolByName - --import unittest2 as unittest -+import unittest - - - class TestIterations(unittest.TestCase): - - -Repository: plone.app.iterate - - -Branch: refs/heads/master -Date: 2016-12-22T12:10:50-06:00 +Date: 2016-12-23T14:05:06-06:00 Author: Johannes Raggam (thet) -Commit: https://github.com/plone/plone.app.iterate/commit/8add6d7c2cedc851108880f900e4832f40c3dd80 +Commit: https://github.com/plone/mockup/commit/07ee4ec96989c76cbfe5ab4cf447af042325a454 -Merge pull request #38 from plone/jensens-remove-at-dependency - -do not hard depend on Archetypes anymore +simple eslint fix Files changed: -A plone/app/iterate/at.zcml -A plone/app/iterate/base.py -M CHANGES.rst -M plone/app/iterate/configure.zcml -M plone/app/iterate/copier.py -M plone/app/iterate/dexterity/copier.py -M plone/app/iterate/dexterity/policy.py -M plone/app/iterate/dexterity/relation.py -M plone/app/iterate/dexterity/utils.py -M plone/app/iterate/interfaces.py -M plone/app/iterate/policy.py -M plone/app/iterate/profiles/test/portal_placeful_workflow/working-copy.xml -M plone/app/iterate/relation.py -M plone/app/iterate/testing.py -M plone/app/iterate/tests/test_interfaces.py -M plone/app/iterate/tests/test_iterate.py -M setup.py - -diff --git a/CHANGES.rst b/CHANGES.rst -index 42f1217..5d4bda7 100644 ---- a/CHANGES.rst -+++ b/CHANGES.rst -@@ -1,7 +1,7 @@ - Changelog - ========= - --3.2.4 (unreleased) -+3.3.0 (unreleased) - ------------------ - - Breaking changes: -@@ -10,10 +10,15 @@ Breaking changes: - - New features: - --- *add item here* -+- Do not depend on Products.Archetypes anymore. -+ If Archetypes is present it still registers the adapters. -+ [jensens] - - Bug fixes: - -+- Do not use unittest2 anymore. -+ [jensens] -+ - - Cleanup: isort, zca decorators, etc. - [jensens] - -diff --git a/plone/app/iterate/at.zcml b/plone/app/iterate/at.zcml -new file mode 100644 -index 0000000..e6b938f ---- /dev/null -+++ b/plone/app/iterate/at.zcml -@@ -0,0 +1,15 @@ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -\ No newline at end of file -diff --git a/plone/app/iterate/base.py b/plone/app/iterate/base.py -new file mode 100644 -index 0000000..c2e895b ---- /dev/null -+++ b/plone/app/iterate/base.py -@@ -0,0 +1,99 @@ -+# -*- coding: utf-8 -*- -+################################################################## -+# -+# (C) Copyright 2006-2007 ObjectRealms, LLC -+# (C) Copyright 2007-2017 Plone Foundation -+# All Rights Reserved -+# -+# This file is part of iterate. -+# -+# iterate is free software; you can redistribute it and/or modify -+# it under the terms of the GNU General Public License as published by -+# the Free Software Foundation; either version 2 of the License, or -+# (at your option) any later version. -+# -+# iterate is distributed in the hope that it will be useful, -+# but WITHOUT ANY WARRANTY; without even the implied warranty of -+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+# GNU General Public License for more details. -+# -+# You should have received a copy of the GNU General Public License -+# along with CMFDeployment; if not, write to the Free Software -+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -+################################################################## -+""" -+Base Checkin Checkout Policy For Content -+ -+""" -+ -+from Acquisition import aq_inner -+from Acquisition import aq_parent -+from plone.app.iterate.event import BeforeCheckoutEvent -+from plone.app.iterate.event import CancelCheckoutEvent -+from plone.app.iterate.event import CheckoutEvent -+from plone.app.iterate.interfaces import ICheckinCheckoutPolicy -+from plone.app.iterate.interfaces import IObjectCopier -+from plone.app.iterate.util import get_storage -+from zope.component import queryAdapter -+from zope.event import notify -+from zope.interface import implementer -+ -+ -+@implementer(ICheckinCheckoutPolicy) -+class CheckinCheckoutBasePolicyAdapter(object): -+ """Base Checkin Checkout Policy For Content -+ -+ - on checkout context is the baseline -+ - on checkin context is the working copy. -+ -+ """ -+ -+ # used when creating baseline version for first time -+ default_base_message = 'Created Baseline' -+ -+ def __init__(self, context): -+ self.context = context -+ -+ def checkin(self, checkin_message): -+ raise NotImplemented() -+ -+ def checkout(self, container): -+ # see interface -+ notify(BeforeCheckoutEvent(self.context)) -+ -+ # use the object copier to checkout the content to the container -+ copier = queryAdapter(self.context, IObjectCopier) -+ working_copy, relation = copier.copyTo(container) -+ -+ # publish the event for any subscribers -+ notify(CheckoutEvent(self.context, working_copy, relation)) -+ -+ # finally return the working copy -+ return working_copy -+ -+ def cancelCheckout(self): -+ # see interface -+ -+ # get the baseline -+ baseline = self._getBaseline() -+ -+ # publish an event -+ notify(CancelCheckoutEvent(self.context, baseline)) -+ -+ # delete the working copy -+ wc_container = aq_parent(aq_inner(self.context)) -+ wc_container.manage_delObjects([self.context.getId()]) -+ -+ return baseline -+ -+ ################################# -+ # Checkin Support Methods -+ -+ def getBaseline(self): -+ raise NotImplemented() -+ -+ def getWorkingCopy(self): -+ raise NotImplemented() -+ -+ def getProperties(self, obj, default=None): -+ return get_storage(obj, default=default) -diff --git a/plone/app/iterate/configure.zcml b/plone/app/iterate/configure.zcml -index 5b5f395..39a2f62 100644 ---- a/plone/app/iterate/configure.zcml -+++ b/plone/app/iterate/configure.zcml -@@ -65,15 +65,7 @@ - factory=".profiles.HiddenProfiles" - /> - -- -- -- -- -- -- -- - -- - - - - - -+ - - -diff --git a/plone/app/iterate/copier.py b/plone/app/iterate/copier.py -index 70e0fa3..ef6dc0b 100644 ---- a/plone/app/iterate/copier.py -+++ b/plone/app/iterate/copier.py -@@ -22,7 +22,7 @@ - ################################################################## - - """ --$Id: copier.py 1824 2007-02-08 17:59:41Z hazmat $ -+Archtypes specific copier, dexterity folder has its own! - """ - - from Acquisition import aq_base -diff --git a/plone/app/iterate/dexterity/copier.py b/plone/app/iterate/dexterity/copier.py -index 7e6c82b..19bec8a 100644 ---- a/plone/app/iterate/dexterity/copier.py -+++ b/plone/app/iterate/dexterity/copier.py -@@ -16,15 +16,10 @@ - from zope.annotation.interfaces import IAnnotations - from zope.event import notify - from zope.interface import implementer -+from zope.intid.interfaces import IIntIds - from zope.schema import getFieldsInOrder - - --try: -- from zope.intid.interfaces import IIntIds --except ImportError: -- from zope.app.intid.interfaces import IIntIds -- -- - @implementer(interfaces.IObjectCopier) - class ContentCopier(copier.ContentCopier): - -diff --git a/plone/app/iterate/dexterity/policy.py b/plone/app/iterate/dexterity/policy.py -index a7496fc..14d1ea4 100644 ---- a/plone/app/iterate/dexterity/policy.py -+++ b/plone/app/iterate/dexterity/policy.py -@@ -1,63 +1,57 @@ - # -*- coding: utf-8 -*- --from plone.app import iterate -+from plone.app.iterate.base import CheckinCheckoutBasePolicyAdapter -+from plone.app.iterate.dexterity.interfaces import IDexterityIterateAware - from plone.app.iterate.dexterity.utils import get_baseline - from plone.app.iterate.dexterity.utils import get_checkout_relation - from plone.app.iterate.dexterity.utils import get_relations - from plone.app.iterate.dexterity.utils import get_working_copy -+from plone.app.iterate.event import AfterCheckinEvent -+from plone.app.iterate.event import CheckinEvent -+from plone.app.iterate.interfaces import CheckinException -+from plone.app.iterate.interfaces import IObjectCopier - from plone.app.iterate.util import get_storage --from zope import component -+from zope.component import adapter -+from zope.component import queryAdapter - from zope.event import notify --from zope.interface import implementer - - --@implementer(iterate.interfaces.ICheckinCheckoutPolicy) --class CheckinCheckoutPolicyAdapter( -- iterate.policy.CheckinCheckoutPolicyAdapter --): -+@adapter(IDexterityIterateAware) -+class CheckinCheckoutPolicyAdapter(CheckinCheckoutBasePolicyAdapter): - """ - Dexterity Checkin Checkout Policy - """ - -+ def checkin(self, checkin_message): -+ # get the baseline for this working copy, raise if not found -+ baseline = self._getBaseline() -+ # get a hold of the relation object -+ relation = self._get_relation_to_baseline() -+ # publish the event for subscribers, early because contexts are about -+ # to be manipulated -+ notify(CheckinEvent(self.context, baseline, relation, checkin_message)) -+ # merge the object back to the baseline with a copier -+ copier = queryAdapter(self.context, IObjectCopier) -+ new_baseline = copier.merge() -+ # don't need to unlock the lock disappears with old baseline deletion -+ notify(AfterCheckinEvent(new_baseline, checkin_message)) -+ return new_baseline -+ - def _get_relation_to_baseline(self): - # do we have a baseline in our relations? - relations = get_relations(self.context) -- - if relations and not len(relations) == 1: -- raise iterate.interfaces.CheckinException( -- 'Baseline count mismatch') -- -+ raise CheckinException('Baseline count mismatch') - if not relations or not relations[0]: -- raise iterate.interfaces.CheckinException( -- 'Baseline has disappeared') -+ raise CheckinException('Baseline has disappeared') - - return relations[0] - - def _getBaseline(self): - baseline = get_baseline(self.context) - if not baseline: -- raise iterate.interfaces.CheckinException( -- 'Baseline has disappeared') -+ raise CheckinException('Baseline has disappeared') - return baseline - -- def checkin(self, checkin_message): -- # get the baseline for this working copy, raise if not found -- baseline = self._getBaseline() -- # get a hold of the relation object -- relation = self._get_relation_to_baseline() -- # publish the event for subscribers, early because contexts are about -- # to be manipulated -- notify(iterate.event.CheckinEvent(self.context, -- baseline, -- relation, -- checkin_message)) -- # merge the object back to the baseline with a copier -- copier = component.queryAdapter(self.context, -- iterate.interfaces.IObjectCopier) -- new_baseline = copier.merge() -- # don't need to unlock the lock disappears with old baseline deletion -- notify(iterate.event.AfterCheckinEvent(new_baseline, checkin_message)) -- return new_baseline -- - def getBaseline(self): - return get_baseline(self.context) - -diff --git a/plone/app/iterate/dexterity/relation.py b/plone/app/iterate/dexterity/relation.py -index fa3b054..8c2eca1 100644 ---- a/plone/app/iterate/dexterity/relation.py -+++ b/plone/app/iterate/dexterity/relation.py -@@ -5,12 +5,7 @@ - from zope.annotation.interfaces import IAttributeAnnotatable - from zope.component import getUtility - from zope.interface import implementer -- -- --try: -- from zope.intid.interfaces import IIntIds --except ImportError: -- from zope.app.intid.interfaces import IIntIds -+from zope.intid.interfaces import IIntIds - - - @implementer(IStagingRelationValue, IAttributeAnnotatable) -diff --git a/plone/app/iterate/dexterity/utils.py b/plone/app/iterate/dexterity/utils.py -index ad7bada..2ec7357 100644 ---- a/plone/app/iterate/dexterity/utils.py -+++ b/plone/app/iterate/dexterity/utils.py -@@ -4,12 +4,7 @@ - from plone.app.iterate.dexterity import ITERATE_RELATION_NAME - from zc.relation.interfaces import ICatalog - from zope import component -- -- --try: -- from zope.intid.interfaces import IIntIds --except ImportError: -- from zope.app.intid.interfaces import IIntIds -+from zope.intid.interfaces import IIntIds - - - def get_relations(context): -diff --git a/plone/app/iterate/interfaces.py b/plone/app/iterate/interfaces.py -index 1656454..3262538 100644 ---- a/plone/app/iterate/interfaces.py -+++ b/plone/app/iterate/interfaces.py -@@ -27,12 +27,23 @@ - from plone.app.iterate import PloneMessageFactory as _ - from plone.locking.interfaces import LockType - from plone.locking.interfaces import MAX_TIMEOUT --from Products.Archetypes.interfaces import IReference - from zope import schema - from zope.component.interfaces import IObjectEvent - from zope.interface import Attribute - from zope.interface import Interface - -+import pkg_resources -+ -+ -+try: -+ pkg_resources.get_distribution('Products.Archetypes') -+except pkg_resources.DistributionNotFound: -+ -+ class IReference(Interface): -+ pass -+else: -+ from Products.Archetypes.interfaces import IReference -+ - - ################################ - # Marker interface -diff --git a/plone/app/iterate/policy.py b/plone/app/iterate/policy.py -index f7109f0..ac0fa4e 100644 ---- a/plone/app/iterate/policy.py -+++ b/plone/app/iterate/policy.py -@@ -21,58 +21,31 @@ - # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - ################################################################## - """ --A Default Checkin Checkout Policy For Content -+Archetypes Checkin Checkout Policy For Content - - """ -- --from Acquisition import aq_inner --from Acquisition import aq_parent -+from plone.app.iterate.base import CheckinCheckoutBasePolicyAdapter -+from plone.app.iterate.event import AfterCheckinEvent -+from plone.app.iterate.event import CheckinEvent -+from plone.app.iterate.interfaces import CheckinException -+from plone.app.iterate.interfaces import IIterateAware -+from plone.app.iterate.interfaces import IObjectCopier -+from plone.app.iterate.relation import WorkingCopyRelation - from plone.app.iterate.util import get_storage - from Products.Archetypes.interfaces import IReferenceable --from relation import WorkingCopyRelation --from zope import component -+from zope.component import adapter -+from zope.component import queryAdapter - from zope.event import notify --from zope.interface import implementer -- --import event --import interfaces -- -- --@implementer(interfaces.ICheckinCheckoutPolicy) --@component.adapter(interfaces.IIterateAware) --class CheckinCheckoutPolicyAdapter(object): -- """ -- Default Checkin Checkout Policy For Content -- -- on checkout context is the baseline - -- on checkin context is the working copy. - -- This default Policy works with Archetypes. -+@adapter(IIterateAware) -+class CheckinCheckoutPolicyAdapter(CheckinCheckoutBasePolicyAdapter): -+ """Checkin Checkout Policy For Archetypes Content - -- dexterity folder has dexterity compatible one -+ - on checkout context is the baseline -+ - on checkin context is the working copy. - """ - -- # used when creating baseline version for first time -- default_base_message = 'Created Baseline' -- -- def __init__(self, context): -- self.context = context -- -- def checkout(self, container): -- # see interface -- notify(event.BeforeCheckoutEvent(self.context)) -- -- # use the object copier to checkout the content to the container -- copier = component.queryAdapter(self.context, interfaces.IObjectCopier) -- working_copy, relation = copier.copyTo(container) -- -- # publish the event for any subscribers -- notify(event.CheckoutEvent(self.context, working_copy, relation)) -- -- # finally return the working copy -- return working_copy -- - def checkin(self, checkin_message): - # see interface - -@@ -81,40 +54,25 @@ def checkin(self, checkin_message): - - # get a hold of the relation object - wc_ref = self.context.getReferenceImpl( -- WorkingCopyRelation.relationship)[0] -+ WorkingCopyRelation.relationship -+ )[0] - - # publish the event for subscribers, early because contexts are about - # to be manipulated -- notify(event.CheckinEvent(self.context, -- baseline, wc_ref, checkin_message)) -+ notify(CheckinEvent(self.context, baseline, wc_ref, checkin_message)) - - # merge the object back to the baseline with a copier - - # XXX by gotcha - # bug we should or use a getAdapter call or test if copier is None -- copier = component.queryAdapter(self.context, interfaces.IObjectCopier) -+ copier = queryAdapter(self.context, IObjectCopier) - new_baseline = copier.merge() - - # don't need to unlock the lock disappears with old baseline deletion -- notify(event.AfterCheckinEvent(new_baseline, checkin_message)) -+ notify(AfterCheckinEvent(new_baseline, checkin_message)) - - return new_baseline - -- def cancelCheckout(self): -- # see interface -- -- # get the baseline -- baseline = self._getBaseline() -- -- # publish an event -- notify(event.CancelCheckoutEvent(self.context, baseline)) -- -- # delete the working copy -- wc_container = aq_parent(aq_inner(self.context)) -- wc_container.manage_delObjects([self.context.getId()]) -- -- return baseline -- - ################################# - # Checkin Support Methods - -@@ -123,10 +81,10 @@ def _getBaseline(self): - refs = self.context.getReferences(WorkingCopyRelation.relationship) - - if not len(refs) == 1: -- raise interfaces.CheckinException('Baseline count mismatch') -+ raise CheckinException('Baseline count mismatch') - - if not refs or refs[0] is None: -- raise interfaces.CheckinException('Baseline has disappeared') -+ raise CheckinException('Baseline has disappeared') - - baseline = refs[0] - return baseline -diff --git a/plone/app/iterate/profiles/test/portal_placeful_workflow/working-copy.xml b/plone/app/iterate/profiles/test/portal_placeful_workflow/working-copy.xml -index 938d3a3..a999931 100644 ---- a/plone/app/iterate/profiles/test/portal_placeful_workflow/working-copy.xml -+++ b/plone/app/iterate/profiles/test/portal_placeful_workflow/working-copy.xml -@@ -5,6 +5,6 @@ - - - -- -+ - - -diff --git a/plone/app/iterate/relation.py b/plone/app/iterate/relation.py -index bc96439..bcfa0b1 100644 ---- a/plone/app/iterate/relation.py -+++ b/plone/app/iterate/relation.py -@@ -21,7 +21,7 @@ - # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - ################################################################## - """ --$Id: relation.py 1392 2006-06-20 01:02:17Z hazmat $ -+Archetypes speicifc implementation for relation handling - """ - - from interfaces import ICheckinCheckoutReference -diff --git a/plone/app/iterate/testing.py b/plone/app/iterate/testing.py -index cd0484b..95b9136 100644 ---- a/plone/app/iterate/testing.py -+++ b/plone/app/iterate/testing.py -@@ -8,6 +8,16 @@ - from plone.app.testing.layers import IntegrationTesting - from plone.testing import z2 - -+import pkg_resources -+ -+ -+try: -+ pkg_resources.get_distribution('Products.Archetypes') -+except pkg_resources.DistributionNotFound: -+ HAS_AT = False -+else: -+ HAS_AT = True -+ - - ADMIN = { - 'id': 'admin', -@@ -42,14 +52,15 @@ class PloneAppIterateLayer(PloneSandboxLayer): - - def setUpZope(self, app, configurationContext): - """Setup Zope with Addons.""" -- import Products.ATContentTypes -- self.loadZCML(package=Products.ATContentTypes) -- z2.installProduct(app, 'Products.ATContentTypes') -+ if HAS_AT: -+ import Products.ATContentTypes -+ self.loadZCML(package=Products.ATContentTypes) -+ z2.installProduct(app, 'Products.ATContentTypes') - -- z2.installProduct(app, 'Products.Archetypes') -- z2.installProduct(app, 'Products.ATContentTypes') -- z2.installProduct(app, 'plone.app.blob') -- z2.installProduct(app, 'plone.app.collection') -+ z2.installProduct(app, 'Products.Archetypes') -+ z2.installProduct(app, 'Products.ATContentTypes') -+ z2.installProduct(app, 'plone.app.blob') -+ z2.installProduct(app, 'plone.app.collection') - - import plone.app.iterate - self.loadZCML(package=plone.app.iterate) -@@ -59,9 +70,9 @@ def setUpPloneSite(self, portal): - # restore default workflow - applyProfile(portal, 'Products.CMFPlone:testfixture') - -- # add default content -- applyProfile(portal, 'Products.ATContentTypes:content') -- -+ if HAS_AT: -+ # add default content -+ applyProfile(portal, 'Products.ATContentTypes:content') - applyProfile(portal, 'plone.app.iterate:default') - applyProfile(portal, 'plone.app.iterate:test') - -diff --git a/plone/app/iterate/tests/test_interfaces.py b/plone/app/iterate/tests/test_interfaces.py -index 1b7378c..12b99ca 100644 ---- a/plone/app/iterate/tests/test_interfaces.py -+++ b/plone/app/iterate/tests/test_interfaces.py -@@ -10,7 +10,7 @@ - from plone.app.testing import TEST_USER_ID - from plone.app.testing import TEST_USER_NAME - from plone.dexterity.utils import createContentInContainer --from unittest2 import TestCase -+from unittest import TestCase - - - class TestObjectsProvideCorrectInterfaces(TestCase): -diff --git a/plone/app/iterate/tests/test_iterate.py b/plone/app/iterate/tests/test_iterate.py -index f31539c..0b9dde3 100644 ---- a/plone/app/iterate/tests/test_iterate.py -+++ b/plone/app/iterate/tests/test_iterate.py -@@ -34,7 +34,7 @@ - from plone.app.testing import TEST_USER_NAME - from Products.CMFCore.utils import getToolByName - --import unittest2 as unittest -+import unittest - - - class TestIterations(unittest.TestCase): -diff --git a/setup.py b/setup.py -index fc8f810..7b27d68 100644 ---- a/setup.py -+++ b/setup.py -@@ -57,13 +57,16 @@ - 'zope.lifecycleevent', - 'zope.schema', - 'zope.viewlet', -- 'Zope2', - ], - extras_require={ -+ 'archetypes': [ -+ 'Products.Archetypes', -+ ], - 'test': [ - 'plone.app.testing', - 'plone.app.contenttypes', -- 'plone.app.robotframework' -+ 'plone.app.robotframework', -+ 'Products.Archetypes', - ] - }, - entry_points=""" +M mockup/patterns/relateditems/upload.js + +diff --git a/mockup/patterns/relateditems/upload.js b/mockup/patterns/relateditems/upload.js +index 6f671dc..e2e1cfa 100644 +--- a/mockup/patterns/relateditems/upload.js ++++ b/mockup/patterns/relateditems/upload.js +@@ -44,7 +44,7 @@ define([ + self.popover.hide(); + }, + false +- ) ++ ); + } + // getIcon, getURL, portal_type, review_state, Title, path + // var itemHtml = self.applyTemplate('selection', item);