Skip to content

Commit

Permalink
[fc] Repository: plone.recipe.zope2instance
Browse files Browse the repository at this point in the history
Branch: refs/heads/master
Date: 2021-03-22T10:12:27+01:00
Author: Jens Vagelpohl (dataflake) <jens@netz.ooo>
Commit: plone/plone.recipe.zope2instance@b071b1e

Fixed ``$PYTHONSTARTUP`` file support for the ``debug`` command under Python 3

Files changed:
A news/167.bugfix
M src/plone/recipe/zope2instance/ctl.py
Repository: plone.recipe.zope2instance

Branch: refs/heads/master
Date: 2021-03-22T11:29:00+01:00
Author: Jens Vagelpohl (dataflake) <jens@netz.ooo>
Commit: plone/plone.recipe.zope2instance@047d7de

Merge pull request #168 from plone/dataflake/issue_167

Fix `$PYTHONSTARTUP` file support for the debug command under Python 3

Files changed:
A news/167.bugfix
M src/plone/recipe/zope2instance/ctl.py
  • Loading branch information
dataflake committed Mar 22, 2021
1 parent 05b88b4 commit 1c43441
Showing 1 changed file with 17 additions and 79 deletions.
96 changes: 17 additions & 79 deletions last_commit.txt
Original file line number Diff line number Diff line change
@@ -1,96 +1,34 @@
Repository: plone.api
Repository: plone.recipe.zope2instance


Branch: refs/heads/master
Date: 2021-03-19T16:40:49+01:00
Author: ale-rt (ale-rt) <alessandro.pisa@gmail.com>
Commit: https://github.com/plone/plone.api/commit/98ef9c948a6c4263dac005666300690c6657910e
Date: 2021-03-22T10:12:27+01:00
Author: Jens Vagelpohl (dataflake) <jens@netz.ooo>
Commit: https://github.com/plone/plone.recipe.zope2instance/commit/b071b1e0aa396f5867e9d4603a1ce500d20886a6

Demonstrate that the intids catalog gets broken after moving an object
Fixed ``$PYTHONSTARTUP`` file support for the ``debug`` command under Python 3

Files changed:
M src/plone/api/tests/test_content.py
A news/167.bugfix
M src/plone/recipe/zope2instance/ctl.py

b'diff --git a/src/plone/api/tests/test_content.py b/src/plone/api/tests/test_content.py\nindex fcbecaf..63820a2 100644\n--- a/src/plone/api/tests/test_content.py\n+++ b/src/plone/api/tests/test_content.py\n@@ -113,6 +113,23 @@ def setUp(self):\n id=\'image\',\n )\n \n+ def verify_initids(self):\n+ """Test that the intids are in order"""\n+ try:\n+ from zope.intid.interfaces import IIntIds\n+ except ImportError:\n+ # IntId are not a thing in Plone 4.3\n+ return\n+ from zope.component import getUtility\n+ intids = getUtility(IIntIds)\n+ broken_keys = [\n+ key for key in intids.ids\n+ if not self.portal.unrestrictedTraverse(key.path, None)\n+ ]\n+ obsolete_paths = [key.path for key in broken_keys]\n+ self.assertListEqual(obsolete_paths, [])\n+\n+\n def test_create_constraints(self):\n """Test the constraints when creating content."""\n from plone.api.exc import InvalidParameterError\n@@ -242,6 +259,7 @@ def test_create_dexterity(self):\n type=\'Dexterity Item\',\n id=\'test-item\',\n )\n+ self.verify_initids()\n \n def test_create_content(self):\n """Test create content"""\n@@ -289,6 +307,7 @@ def test_create_content(self):\n type=\'Document\',\n id=\'test-document\',\n )\n+ self.verify_initids()\n \n def test_create_with_safe_id(self):\n """Test the content creating with safe_id mode."""\n@@ -552,6 +571,7 @@ def test_move(self):\n container[\'events\'][\'about\']\n and container[\'events\'][\'about\'] == about\n )\n+ self.verify_initids()\n \n def test_move_no_move_if_target_is_source_parent(self):\n """Test that trying to move an object to its parent is a noop"""\n'
b'diff --git a/news/167.bugfix b/news/167.bugfix\nnew file mode 100644\nindex 0000000..8e8e915\n--- /dev/null\n+++ b/news/167.bugfix\n@@ -0,0 +1,2 @@\n+Fixed ``$PYTHONSTARTUP`` file support for the ``debug`` command under Python 3\n+[dataflake]\ndiff --git a/src/plone/recipe/zope2instance/ctl.py b/src/plone/recipe/zope2instance/ctl.py\nindex 75ae39c..560e1e0 100644\n--- a/src/plone/recipe/zope2instance/ctl.py\n+++ b/src/plone/recipe/zope2instance/ctl.py\n@@ -796,11 +796,15 @@ def do_debug(self, arg):\n interactive_startup = (\n "import os;"\n "os.path.exists(os.environ.get(\'PYTHONSTARTUP\', \'\')) "\n- "and execfile(os.environ[\'PYTHONSTARTUP\']); del os;"\n+ "and %s; del os;"\n )\n+ if six.PY2:\n+ exec_call = "execfile(os.environ[\'PYTHONSTARTUP\'])"\n+ else:\n+ exec_call = "exec(open(os.environ[\'PYTHONSTARTUP\']).read())"\n cmdline = self.get_startup_cmd(\n self.options.python,\n- interactive_startup,\n+ interactive_startup % exec_call,\n pyflags=\'-i\',\n )\n print(\'Starting debugger (the name "app" is bound to the top-level \'\n'

Repository: plone.api
Repository: plone.recipe.zope2instance


Branch: refs/heads/master
Date: 2021-03-19T16:48:25+01:00
Author: Maurits van Rees (mauritsvanrees) <maurits@vanrees.org>
Commit: https://github.com/plone/plone.api/commit/b1cb5ec947e29a3b2d83a5bb8014f3c168da106b
Date: 2021-03-22T11:29:00+01:00
Author: Jens Vagelpohl (dataflake) <jens@netz.ooo>
Commit: https://github.com/plone/plone.recipe.zope2instance/commit/047d7de9d41cdf00446f25d61621db2b79a53d35

initids -&gt; intids
Merge pull request #168 from plone/dataflake/issue_167

Files changed:
M src/plone/api/tests/test_content.py

b'diff --git a/src/plone/api/tests/test_content.py b/src/plone/api/tests/test_content.py\nindex 63820a2..d2c9cdc 100644\n--- a/src/plone/api/tests/test_content.py\n+++ b/src/plone/api/tests/test_content.py\n@@ -113,7 +113,7 @@ def setUp(self):\n id=\'image\',\n )\n \n- def verify_initids(self):\n+ def verify_intids(self):\n """Test that the intids are in order"""\n try:\n from zope.intid.interfaces import IIntIds\n@@ -259,7 +259,7 @@ def test_create_dexterity(self):\n type=\'Dexterity Item\',\n id=\'test-item\',\n )\n- self.verify_initids()\n+ self.verify_intids()\n \n def test_create_content(self):\n """Test create content"""\n@@ -307,7 +307,7 @@ def test_create_content(self):\n type=\'Document\',\n id=\'test-document\',\n )\n- self.verify_initids()\n+ self.verify_intids()\n \n def test_create_with_safe_id(self):\n """Test the content creating with safe_id mode."""\n@@ -571,7 +571,7 @@ def test_move(self):\n container[\'events\'][\'about\']\n and container[\'events\'][\'about\'] == about\n )\n- self.verify_initids()\n+ self.verify_intids()\n \n def test_move_no_move_if_target_is_source_parent(self):\n """Test that trying to move an object to its parent is a noop"""\n'

Repository: plone.api


Branch: refs/heads/master
Date: 2021-03-19T16:50:19+01:00
Author: Maurits van Rees (mauritsvanrees) <maurits@vanrees.org>
Commit: https://github.com/plone/plone.api/commit/de0ab8cd96146df3d32842b4f04d3a0bf61de336

Removed 4.3 code from tests.

Files changed:
M src/plone/api/tests/test_content.py

b'diff --git a/src/plone/api/tests/test_content.py b/src/plone/api/tests/test_content.py\nindex d2c9cdc..5cea7fe 100644\n--- a/src/plone/api/tests/test_content.py\n+++ b/src/plone/api/tests/test_content.py\n@@ -115,12 +115,9 @@ def setUp(self):\n \n def verify_intids(self):\n """Test that the intids are in order"""\n- try:\n- from zope.intid.interfaces import IIntIds\n- except ImportError:\n- # IntId are not a thing in Plone 4.3\n- return\n from zope.component import getUtility\n+ from zope.intid.interfaces import IIntIds\n+\n intids = getUtility(IIntIds)\n broken_keys = [\n key for key in intids.ids\n'

Repository: plone.api


Branch: refs/heads/master
Date: 2021-03-19T16:50:19+01:00
Author: Maurits van Rees (mauritsvanrees) <maurits@vanrees.org>
Commit: https://github.com/plone/plone.api/commit/a0c7876b891f45c4025a86dcaeeb981e276f3ce5

Tests: verify that intid keys can be found back.

Files changed:
M src/plone/api/tests/test_content.py

b'diff --git a/src/plone/api/tests/test_content.py b/src/plone/api/tests/test_content.py\nindex 5cea7fe..1332d7d 100644\n--- a/src/plone/api/tests/test_content.py\n+++ b/src/plone/api/tests/test_content.py\n@@ -126,6 +126,14 @@ def verify_intids(self):\n obsolete_paths = [key.path for key in broken_keys]\n self.assertListEqual(obsolete_paths, [])\n \n+ # Objects used as keys with a hash can behave strangely.\n+ # I have seen this go wrong in a production site.\n+ weird_keys = [\n+ key for key in intids.ids\n+ if key not in intids.ids\n+ ]\n+ weird_paths = [key.path for key in weird_keys]\n+ self.assertListEqual(weird_paths, [])\n \n def test_create_constraints(self):\n """Test the constraints when creating content."""\n'

Repository: plone.api


Branch: refs/heads/master
Date: 2021-03-19T17:06:35+01:00
Author: Maurits van Rees (mauritsvanrees) <maurits@vanrees.org>
Commit: https://github.com/plone/plone.api/commit/44bb079d1961577bd19d8f94b4b053e4254958a1

Added news snippet for added intid tests.

See https://github.com/plone/plone.api/issues/430
and https://github.com/plone/five.intid/issues/9#issuecomment-802940554

Files changed:
A news/430.bugfix

b'diff --git a/news/430.bugfix b/news/430.bugfix\nnew file mode 100644\nindex 0000000..56504fe\n--- /dev/null\n+++ b/news/430.bugfix\n@@ -0,0 +1,2 @@\n+Add tests to verify that the intids utility is correct after moving content.\n+[ale-rt, maurits]\n'

Repository: plone.api


Branch: refs/heads/master
Date: 2021-03-22T11:02:14+01:00
Author: Maurits van Rees (mauritsvanrees) <m.van.rees@zestsoftware.nl>
Commit: https://github.com/plone/plone.api/commit/403b15276490ad4811789abea4f5af02cf9af47a

Merge pull request #456 from plone/maurits/verify-intids-in-tests

Verify intids in tests
Fix `$PYTHONSTARTUP` file support for the debug command under Python 3

Files changed:
A news/430.bugfix
M src/plone/api/tests/test_content.py
A news/167.bugfix
M src/plone/recipe/zope2instance/ctl.py

b'diff --git a/news/430.bugfix b/news/430.bugfix\nnew file mode 100644\nindex 0000000..56504fe\n--- /dev/null\n+++ b/news/430.bugfix\n@@ -0,0 +1,2 @@\n+Add tests to verify that the intids utility is correct after moving content.\n+[ale-rt, maurits]\ndiff --git a/src/plone/api/tests/test_content.py b/src/plone/api/tests/test_content.py\nindex fcbecaf..1332d7d 100644\n--- a/src/plone/api/tests/test_content.py\n+++ b/src/plone/api/tests/test_content.py\n@@ -113,6 +113,28 @@ def setUp(self):\n id=\'image\',\n )\n \n+ def verify_intids(self):\n+ """Test that the intids are in order"""\n+ from zope.component import getUtility\n+ from zope.intid.interfaces import IIntIds\n+\n+ intids = getUtility(IIntIds)\n+ broken_keys = [\n+ key for key in intids.ids\n+ if not self.portal.unrestrictedTraverse(key.path, None)\n+ ]\n+ obsolete_paths = [key.path for key in broken_keys]\n+ self.assertListEqual(obsolete_paths, [])\n+\n+ # Objects used as keys with a hash can behave strangely.\n+ # I have seen this go wrong in a production site.\n+ weird_keys = [\n+ key for key in intids.ids\n+ if key not in intids.ids\n+ ]\n+ weird_paths = [key.path for key in weird_keys]\n+ self.assertListEqual(weird_paths, [])\n+\n def test_create_constraints(self):\n """Test the constraints when creating content."""\n from plone.api.exc import InvalidParameterError\n@@ -242,6 +264,7 @@ def test_create_dexterity(self):\n type=\'Dexterity Item\',\n id=\'test-item\',\n )\n+ self.verify_intids()\n \n def test_create_content(self):\n """Test create content"""\n@@ -289,6 +312,7 @@ def test_create_content(self):\n type=\'Document\',\n id=\'test-document\',\n )\n+ self.verify_intids()\n \n def test_create_with_safe_id(self):\n """Test the content creating with safe_id mode."""\n@@ -552,6 +576,7 @@ def test_move(self):\n container[\'events\'][\'about\']\n and container[\'events\'][\'about\'] == about\n )\n+ self.verify_intids()\n \n def test_move_no_move_if_target_is_source_parent(self):\n """Test that trying to move an object to its parent is a noop"""\n'
b'diff --git a/news/167.bugfix b/news/167.bugfix\nnew file mode 100644\nindex 0000000..8e8e915\n--- /dev/null\n+++ b/news/167.bugfix\n@@ -0,0 +1,2 @@\n+Fixed ``$PYTHONSTARTUP`` file support for the ``debug`` command under Python 3\n+[dataflake]\ndiff --git a/src/plone/recipe/zope2instance/ctl.py b/src/plone/recipe/zope2instance/ctl.py\nindex 75ae39c..560e1e0 100644\n--- a/src/plone/recipe/zope2instance/ctl.py\n+++ b/src/plone/recipe/zope2instance/ctl.py\n@@ -796,11 +796,15 @@ def do_debug(self, arg):\n interactive_startup = (\n "import os;"\n "os.path.exists(os.environ.get(\'PYTHONSTARTUP\', \'\')) "\n- "and execfile(os.environ[\'PYTHONSTARTUP\']); del os;"\n+ "and %s; del os;"\n )\n+ if six.PY2:\n+ exec_call = "execfile(os.environ[\'PYTHONSTARTUP\'])"\n+ else:\n+ exec_call = "exec(open(os.environ[\'PYTHONSTARTUP\']).read())"\n cmdline = self.get_startup_cmd(\n self.options.python,\n- interactive_startup,\n+ interactive_startup % exec_call,\n pyflags=\'-i\',\n )\n print(\'Starting debugger (the name "app" is bound to the top-level \'\n'

0 comments on commit 1c43441

Please sign in to comment.