-
-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Branch: refs/heads/master Date: 2021-05-19T22:17:08+02:00 Author: Michael Graf (2silver) <[email protected]> Commit: plone/plone.app.iterate@2273192 fix: update relations on Check-In fix #89 Files changed: M plone/app/iterate/dexterity/policy.py M plone/app/iterate/tests/test_iterate.py Repository: plone.app.iterate Branch: refs/heads/master Date: 2021-05-20T07:58:19+02:00 Author: Michael Graf (2silver) <[email protected]> Commit: plone/plone.app.iterate@8c061e4 chore: remove debug comment Files changed: M plone/app/iterate/tests/test_iterate.py Repository: plone.app.iterate Branch: refs/heads/master Date: 2021-05-20T08:02:32+02:00 Author: Michael Graf (2silver) <[email protected]> Commit: plone/plone.app.iterate@1cc0648 chore: black and flake8 Files changed: M plone/app/iterate/tests/test_iterate.py Repository: plone.app.iterate Branch: refs/heads/master Date: 2021-05-20T08:07:54+02:00 Author: Michael Graf (2silver) <[email protected]> Commit: plone/plone.app.iterate@8cead3c chore: add changes message Files changed: A news/89.bugfix Repository: plone.app.iterate Branch: refs/heads/master Date: 2021-05-23T00:32:51+02:00 Author: Jens W. Klein (jensens) <[email protected]> Commit: plone/plone.app.iterate@0ed2747 Merge pull request #90 from plone/base_rels_update_on_checkin fix: update relations on Check-In fix #89 Files changed: A news/89.bugfix M plone/app/iterate/dexterity/policy.py M plone/app/iterate/tests/test_iterate.py
- Loading branch information
Showing
1 changed file
with
63 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,80 @@ | ||
Repository: plone.registry | ||
Repository: plone.app.iterate | ||
|
||
|
||
Branch: refs/heads/master | ||
Date: 2021-05-19T18:46:55+02:00 | ||
Author: Jens W. Klein (jensens) <[email protected]> | ||
Commit: https://github.com/plone/plone.registry/commit/23bdeff2ed601d2ec6cb8f969671496e8a306bdc | ||
Date: 2021-05-19T22:17:08+02:00 | ||
Author: Michael Graf (2silver) <[email protected]> | ||
Commit: https://github.com/plone/plone.app.iterate/commit/2273192e87d3f84929646b63c4df838733becb1f | ||
|
||
fix: update relations on Check-In fix #89 | ||
|
||
Files changed: | ||
M plone/app/iterate/dexterity/policy.py | ||
M plone/app/iterate/tests/test_iterate.py | ||
|
||
b'diff --git a/plone/app/iterate/dexterity/policy.py b/plone/app/iterate/dexterity/policy.py\nindex f88c69c..e90911c 100644\n--- a/plone/app/iterate/dexterity/policy.py\n+++ b/plone/app/iterate/dexterity/policy.py\n@@ -13,6 +13,7 @@\n from zope.component import adapter\n from zope.component import queryAdapter\n from zope.event import notify\n+from zope.lifecycleevent import ObjectModifiedEvent\n \n \n @adapter(IDexterityIterateAware)\n@@ -34,6 +35,10 @@ def checkin(self, checkin_message):\n new_baseline = copier.merge()\n # don\'t need to unlock the lock disappears with old baseline deletion\n notify(AfterCheckinEvent(new_baseline, checkin_message))\n+\n+ # update our new_baseline, ex. for all References ( and BackReferences)\n+ notify(ObjectModifiedEvent(new_baseline))\n+\n return new_baseline\n \n def _get_relation_to_baseline(self):\ndiff --git a/plone/app/iterate/tests/test_iterate.py b/plone/app/iterate/tests/test_iterate.py\nindex 8fcf288..7a059be 100644\n--- a/plone/app/iterate/tests/test_iterate.py\n+++ b/plone/app/iterate/tests/test_iterate.py\n@@ -281,3 +281,57 @@ def test_relationship_deleted_on_cancel_checkout(self):\n rels = list(catalog.findRelations({"from_id": obj_id}))\n \n self.assertEqual(len(rels), 0)\n+\n+ def test_baseline_relations_updated_on_checkin(self):\n+ # Ensure that relations between the baseline and\n+ # and other objects are up-to-date on checkin\n+ from zope.event import notify\n+ from zope.lifecycleevent import ObjectModifiedEvent\n+ from z3c.relationfield import RelationValue\n+\n+ folder = self.portal.docs\n+ baseline = folder.doc1\n+ target = folder.doc2\n+\n+ intids = component.getUtility(IIntIds)\n+ catalog = component.getUtility(ICatalog)\n+\n+ target_id = intids.getId(target)\n+ target_rel = [RelationValue(target_id)]\n+\n+ # Test, if nothing is present in the relation catalog\n+ rels = list(catalog.findRelations({\'to_id\': target_id}))\n+ self.assertEqual(len(rels), 0)\n+\n+ # set relatedItems on baseline\n+ baseline.relatedItems = target_rel\n+ notify(ObjectModifiedEvent(baseline))\n+\n+ # Test, if relation is present in the relation catalog\n+ rels = list(catalog.findRelations({\'to_id\': target_id}))\n+ self.assertEqual(len(rels), 1)\n+\n+ # proof for empty relations\n+ # baseline.relatedItems = []\n+ # notify(ObjectModifiedEvent(baseline))\n+ # rels = list(catalog.findRelations({\'to_id\': target_id}))\n+ # self.assertEqual(len(rels), 0)\n+\n+ # make a workingcopy from baseline\n+ wc = ICheckinCheckoutPolicy(baseline).checkout(folder)\n+\n+ # remove relations on wc\n+ wc.relatedItems = []\n+ notify(ObjectModifiedEvent(wc))\n+\n+ # baseline -> target relation should be still there, we are on wc\n+ rels = list(catalog.findRelations({\'to_id\': target_id}))\n+ self.assertEqual(len(rels), 1)\n+\n+ # baseline -> target relation should be empty now\n+ # because we replaced our baseline with our wc (with empty relations) \n+ baseline = ICheckinCheckoutPolicy(wc).checkin("updated")\n+ rels = list(catalog.findRelations({\'to_id\': target_id}))\n+\n+ # new baseline\'s relatedItems should be empty\n+ self.assertEqual(len(rels), 0)\n' | ||
|
||
Repository: plone.app.iterate | ||
|
||
|
||
Branch: refs/heads/master | ||
Date: 2021-05-20T07:58:19+02:00 | ||
Author: Michael Graf (2silver) <[email protected]> | ||
Commit: https://github.com/plone/plone.app.iterate/commit/8c061e46e7f1d13cc4cf44e72b28c6a08368ea6d | ||
|
||
chore: remove debug comment | ||
|
||
Files changed: | ||
M plone/app/iterate/tests/test_iterate.py | ||
|
||
b"diff --git a/plone/app/iterate/tests/test_iterate.py b/plone/app/iterate/tests/test_iterate.py\nindex 7a059be..1662ad1 100644\n--- a/plone/app/iterate/tests/test_iterate.py\n+++ b/plone/app/iterate/tests/test_iterate.py\n@@ -311,12 +311,6 @@ def test_baseline_relations_updated_on_checkin(self):\n rels = list(catalog.findRelations({'to_id': target_id}))\n self.assertEqual(len(rels), 1)\n \n- # proof for empty relations\n- # baseline.relatedItems = []\n- # notify(ObjectModifiedEvent(baseline))\n- # rels = list(catalog.findRelations({'to_id': target_id}))\n- # self.assertEqual(len(rels), 0)\n-\n # make a workingcopy from baseline\n wc = ICheckinCheckoutPolicy(baseline).checkout(folder)\n \n" | ||
|
||
Fix key validation regexp | ||
Repository: plone.app.iterate | ||
|
||
|
||
Branch: refs/heads/master | ||
Date: 2021-05-20T08:02:32+02:00 | ||
Author: Michael Graf (2silver) <[email protected]> | ||
Commit: https://github.com/plone/plone.app.iterate/commit/1cc0648d506b8c77a2f0ddc00de14436e4fea89b | ||
|
||
chore: black and flake8 | ||
|
||
Files changed: | ||
A news/23.bugfix | ||
M plone/registry/registry.py | ||
M plone/app/iterate/tests/test_iterate.py | ||
|
||
b'diff --git a/news/23.bugfix b/news/23.bugfix\nnew file mode 100644\nindex 0000000..366cc44\n--- /dev/null\n+++ b/news/23.bugfix\n@@ -0,0 +1,2 @@\n+Fix registry key validation regexp.\n+[jensens]\n\\ No newline at end of file\ndiff --git a/plone/registry/registry.py b/plone/registry/registry.py\nindex cfaf0da..c14f5d1 100644\n--- a/plone/registry/registry.py\n+++ b/plone/registry/registry.py\n@@ -172,12 +172,9 @@ class _Records(object):\n \n # Similar to zope.schema._field._isdotted, but allows up to one \'/\'\n _validkey = re.compile(\n- r"([a-zA-Z][a-zA-Z0-9_-]*)"\n- r"([.][a-zA-Z][a-zA-Z0-9_-]*)*"\n- r"([/][a-zA-Z][a-zA-Z0-9_-]*)?"\n- r"([.][a-zA-Z][a-zA-Z0-9_-]*)*"\n- # use the whole line\n- r"$").match\n+ r"([a-zA-Z][a-zA-Z0-9_-]*)((?:\\.[a-zA-Z0-9][a-zA-Z0-9_-]*)*)"\n+ r"([/][a-zA-Z0-9][a-zA-Z0-9_-]*)?((?:\\.[a-zA-Z0-9][a-zA-Z0-9_-]*)*)$"\n+ ).match\n \n def __init__(self, parent):\n self.__parent__ = parent\n' | ||
b'diff --git a/plone/app/iterate/tests/test_iterate.py b/plone/app/iterate/tests/test_iterate.py\nindex 1662ad1..9739f6a 100644\n--- a/plone/app/iterate/tests/test_iterate.py\n+++ b/plone/app/iterate/tests/test_iterate.py\n@@ -142,9 +142,13 @@ def test_folderContents(self):\n version of the folder. UIDs of contained content are also\n preserved."""\n container = self.portal.docs\n- folder = container[container.invokeFactory(type_name="Folder", id="foo-folder")]\n+ folder = container[\n+ container.invokeFactory(type_name="Folder", id="foo-folder")\n+ ]\n existing_doc = folder[\n- folder.invokeFactory(type_name="Document", id="existing-folder-item")\n+ folder.invokeFactory(\n+ type_name="Document", id="existing-folder-item"\n+ )\n ]\n existing_doc_uid = existing_doc.UID()\n \n@@ -152,7 +156,9 @@ def test_folderContents(self):\n wc = ICheckinCheckoutPolicy(folder).checkout(container)\n new_doc = wc[\n wc.invokeFactory(\n- type_name="Document", id="new-folder-item", text="new folder item text"\n+ type_name="Document",\n+ id="new-folder-item",\n+ text="new folder item text",\n )\n ]\n new_doc_uid = new_doc.UID()\n@@ -161,10 +167,14 @@ def test_folderContents(self):\n catalog = getToolByName(self.portal, "portal_catalog")\n \n self.assertTrue("existing-folder-item" in new_folder)\n- self.assertEqual(new_folder["existing-folder-item"].UID(), existing_doc_uid)\n+ self.assertEqual(\n+ new_folder["existing-folder-item"].UID(), existing_doc_uid\n+ )\n self.assertTrue("new-folder-item" in new_folder)\n self.assertEqual(new_folder["new-folder-item"].UID(), new_doc_uid)\n- brains = catalog(path="/".join(new_folder["new-folder-item"].getPhysicalPath()))\n+ brains = catalog(\n+ path="/".join(new_folder["new-folder-item"].getPhysicalPath())\n+ )\n self.assertTrue(brains)\n self.assertTrue(\n "new folder item text" in new_folder["new-folder-item"].getText()\n@@ -300,7 +310,7 @@ def test_baseline_relations_updated_on_checkin(self):\n target_rel = [RelationValue(target_id)]\n \n # Test, if nothing is present in the relation catalog\n- rels = list(catalog.findRelations({\'to_id\': target_id}))\n+ rels = list(catalog.findRelations({"to_id": target_id}))\n self.assertEqual(len(rels), 0)\n \n # set relatedItems on baseline\n@@ -308,7 +318,7 @@ def test_baseline_relations_updated_on_checkin(self):\n notify(ObjectModifiedEvent(baseline))\n \n # Test, if relation is present in the relation catalog\n- rels = list(catalog.findRelations({\'to_id\': target_id}))\n+ rels = list(catalog.findRelations({"to_id": target_id}))\n self.assertEqual(len(rels), 1)\n \n # make a workingcopy from baseline\n@@ -319,13 +329,13 @@ def test_baseline_relations_updated_on_checkin(self):\n notify(ObjectModifiedEvent(wc))\n \n # baseline -> target relation should be still there, we are on wc\n- rels = list(catalog.findRelations({\'to_id\': target_id}))\n+ rels = list(catalog.findRelations({"to_id": target_id}))\n self.assertEqual(len(rels), 1)\n \n # baseline -> target relation should be empty now\n- # because we replaced our baseline with our wc (with empty relations) \n+ # because we replaced our baseline with our wc (with empty relations)\n baseline = ICheckinCheckoutPolicy(wc).checkin("updated")\n- rels = list(catalog.findRelations({\'to_id\': target_id}))\n+ rels = list(catalog.findRelations({"to_id": target_id}))\n \n # new baseline\'s relatedItems should be empty\n self.assertEqual(len(rels), 0)\n' | ||
|
||
Repository: plone.registry | ||
Repository: plone.app.iterate | ||
|
||
|
||
Branch: refs/heads/master | ||
Date: 2021-05-19T22:10:10+03:00 | ||
Author: Maik Derstappen (MrTango) <[email protected]> | ||
Commit: https://github.com/plone/plone.registry/commit/ac0acd907ee1a22166a990783de1334762013b2b | ||
Date: 2021-05-20T08:07:54+02:00 | ||
Author: Michael Graf (2silver) <[email protected]> | ||
Commit: https://github.com/plone/plone.app.iterate/commit/8cead3cbcc55cb167695916dda02fad86835425b | ||
|
||
chore: add changes message | ||
|
||
Files changed: | ||
A news/89.bugfix | ||
|
||
b'diff --git a/news/89.bugfix b/news/89.bugfix\nnew file mode 100644\nindex 0000000..6a24dd6\n--- /dev/null\n+++ b/news/89.bugfix\n@@ -0,0 +1,3 @@\n+- Update relations on Check-In WorkingCopy, by trigger an ObjectModifiedEvent event\n+- black and flake8 formatting\n+[2silver]\n\\ No newline at end of file\n' | ||
|
||
Repository: plone.app.iterate | ||
|
||
|
||
Branch: refs/heads/master | ||
Date: 2021-05-23T00:32:51+02:00 | ||
Author: Jens W. Klein (jensens) <[email protected]> | ||
Commit: https://github.com/plone/plone.app.iterate/commit/0ed27470fba9ec32079f138e30d281b4971e22df | ||
|
||
Merge pull request #23 from plone/fix-key-validation | ||
Merge pull request #90 from plone/base_rels_update_on_checkin | ||
|
||
Fix key validation regexp | ||
fix: update relations on Check-In fix #89 | ||
|
||
Files changed: | ||
A news/23.bugfix | ||
M plone/registry/registry.py | ||
A news/89.bugfix | ||
M plone/app/iterate/dexterity/policy.py | ||
M plone/app/iterate/tests/test_iterate.py | ||
|
||
b'diff --git a/news/23.bugfix b/news/23.bugfix\nnew file mode 100644\nindex 0000000..366cc44\n--- /dev/null\n+++ b/news/23.bugfix\n@@ -0,0 +1,2 @@\n+Fix registry key validation regexp.\n+[jensens]\n\\ No newline at end of file\ndiff --git a/plone/registry/registry.py b/plone/registry/registry.py\nindex cfaf0da..c14f5d1 100644\n--- a/plone/registry/registry.py\n+++ b/plone/registry/registry.py\n@@ -172,12 +172,9 @@ class _Records(object):\n \n # Similar to zope.schema._field._isdotted, but allows up to one \'/\'\n _validkey = re.compile(\n- r"([a-zA-Z][a-zA-Z0-9_-]*)"\n- r"([.][a-zA-Z][a-zA-Z0-9_-]*)*"\n- r"([/][a-zA-Z][a-zA-Z0-9_-]*)?"\n- r"([.][a-zA-Z][a-zA-Z0-9_-]*)*"\n- # use the whole line\n- r"$").match\n+ r"([a-zA-Z][a-zA-Z0-9_-]*)((?:\\.[a-zA-Z0-9][a-zA-Z0-9_-]*)*)"\n+ r"([/][a-zA-Z0-9][a-zA-Z0-9_-]*)?((?:\\.[a-zA-Z0-9][a-zA-Z0-9_-]*)*)$"\n+ ).match\n \n def __init__(self, parent):\n self.__parent__ = parent\n' | ||
b'diff --git a/news/89.bugfix b/news/89.bugfix\nnew file mode 100644\nindex 0000000..6a24dd6\n--- /dev/null\n+++ b/news/89.bugfix\n@@ -0,0 +1,3 @@\n+- Update relations on Check-In WorkingCopy, by trigger an ObjectModifiedEvent event\n+- black and flake8 formatting\n+[2silver]\n\\ No newline at end of file\ndiff --git a/plone/app/iterate/dexterity/policy.py b/plone/app/iterate/dexterity/policy.py\nindex f88c69c..e90911c 100644\n--- a/plone/app/iterate/dexterity/policy.py\n+++ b/plone/app/iterate/dexterity/policy.py\n@@ -13,6 +13,7 @@\n from zope.component import adapter\n from zope.component import queryAdapter\n from zope.event import notify\n+from zope.lifecycleevent import ObjectModifiedEvent\n \n \n @adapter(IDexterityIterateAware)\n@@ -34,6 +35,10 @@ def checkin(self, checkin_message):\n new_baseline = copier.merge()\n # don\'t need to unlock the lock disappears with old baseline deletion\n notify(AfterCheckinEvent(new_baseline, checkin_message))\n+\n+ # update our new_baseline, ex. for all References ( and BackReferences)\n+ notify(ObjectModifiedEvent(new_baseline))\n+\n return new_baseline\n \n def _get_relation_to_baseline(self):\ndiff --git a/plone/app/iterate/tests/test_iterate.py b/plone/app/iterate/tests/test_iterate.py\nindex 8fcf288..9739f6a 100644\n--- a/plone/app/iterate/tests/test_iterate.py\n+++ b/plone/app/iterate/tests/test_iterate.py\n@@ -142,9 +142,13 @@ def test_folderContents(self):\n version of the folder. UIDs of contained content are also\n preserved."""\n container = self.portal.docs\n- folder = container[container.invokeFactory(type_name="Folder", id="foo-folder")]\n+ folder = container[\n+ container.invokeFactory(type_name="Folder", id="foo-folder")\n+ ]\n existing_doc = folder[\n- folder.invokeFactory(type_name="Document", id="existing-folder-item")\n+ folder.invokeFactory(\n+ type_name="Document", id="existing-folder-item"\n+ )\n ]\n existing_doc_uid = existing_doc.UID()\n \n@@ -152,7 +156,9 @@ def test_folderContents(self):\n wc = ICheckinCheckoutPolicy(folder).checkout(container)\n new_doc = wc[\n wc.invokeFactory(\n- type_name="Document", id="new-folder-item", text="new folder item text"\n+ type_name="Document",\n+ id="new-folder-item",\n+ text="new folder item text",\n )\n ]\n new_doc_uid = new_doc.UID()\n@@ -161,10 +167,14 @@ def test_folderContents(self):\n catalog = getToolByName(self.portal, "portal_catalog")\n \n self.assertTrue("existing-folder-item" in new_folder)\n- self.assertEqual(new_folder["existing-folder-item"].UID(), existing_doc_uid)\n+ self.assertEqual(\n+ new_folder["existing-folder-item"].UID(), existing_doc_uid\n+ )\n self.assertTrue("new-folder-item" in new_folder)\n self.assertEqual(new_folder["new-folder-item"].UID(), new_doc_uid)\n- brains = catalog(path="/".join(new_folder["new-folder-item"].getPhysicalPath()))\n+ brains = catalog(\n+ path="/".join(new_folder["new-folder-item"].getPhysicalPath())\n+ )\n self.assertTrue(brains)\n self.assertTrue(\n "new folder item text" in new_folder["new-folder-item"].getText()\n@@ -281,3 +291,51 @@ def test_relationship_deleted_on_cancel_checkout(self):\n rels = list(catalog.findRelations({"from_id": obj_id}))\n \n self.assertEqual(len(rels), 0)\n+\n+ def test_baseline_relations_updated_on_checkin(self):\n+ # Ensure that relations between the baseline and\n+ # and other objects are up-to-date on checkin\n+ from zope.event import notify\n+ from zope.lifecycleevent import ObjectModifiedEvent\n+ from z3c.relationfield import RelationValue\n+\n+ folder = self.portal.docs\n+ baseline = folder.doc1\n+ target = folder.doc2\n+\n+ intids = component.getUtility(IIntIds)\n+ catalog = component.getUtility(ICatalog)\n+\n+ target_id = intids.getId(target)\n+ target_rel = [RelationValue(target_id)]\n+\n+ # Test, if nothing is present in the relation catalog\n+ rels = list(catalog.findRelations({"to_id": target_id}))\n+ self.assertEqual(len(rels), 0)\n+\n+ # set relatedItems on baseline\n+ baseline.relatedItems = target_rel\n+ notify(ObjectModifiedEvent(baseline))\n+\n+ # Test, if relation is present in the relation catalog\n+ rels = list(catalog.findRelations({"to_id": target_id}))\n+ self.assertEqual(len(rels), 1)\n+\n+ # make a workingcopy from baseline\n+ wc = ICheckinCheckoutPolicy(baseline).checkout(folder)\n+\n+ # remove relations on wc\n+ wc.relatedItems = []\n+ notify(ObjectModifiedEvent(wc))\n+\n+ # baseline -> target relation should be still there, we are on wc\n+ rels = list(catalog.findRelations({"to_id": target_id}))\n+ self.assertEqual(len(rels), 1)\n+\n+ # baseline -> target relation should be empty now\n+ # because we replaced our baseline with our wc (with empty relations)\n+ baseline = ICheckinCheckoutPolicy(wc).checkin("updated")\n+ rels = list(catalog.findRelations({"to_id": target_id}))\n+\n+ # new baseline\'s relatedItems should be empty\n+ self.assertEqual(len(rels), 0)\n' | ||
|