From 5e888ea887637157338032737647924ef58abcaa Mon Sep 17 00:00:00 2001 From: ale-rt Date: Sat, 22 Sep 2018 19:30:56 +0200 Subject: [PATCH] [fc] Repository: plone.app.folder Branch: refs/heads/master Date: 2018-09-22T17:56:45+02:00 Author: ale-rt (ale-rt) Commit: https://github.com/plone/plone.app.folder/commit/0a5bbdd324f0841d44f5f8c79d1321e5e56e5dc0 Fix missing ``dict.has_key`` in Python3 Files changed: M CHANGES.rst M src/plone/app/folder/migration.py Repository: plone.app.folder Branch: refs/heads/master Date: 2018-09-22T19:30:56+02:00 Author: Alessandro Pisa (ale-rt) Commit: https://github.com/plone/plone.app.folder/commit/038fca70389e1c6d6af19a2ae0a151580b5f5cf5 Merge pull request #18 from plone/python3 Fix missing ``dict.has_key`` in Python3 Files changed: M CHANGES.rst M src/plone/app/folder/migration.py --- last_commit.txt | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/last_commit.txt b/last_commit.txt index eab3a02acf..a93487ff63 100644 --- a/last_commit.txt +++ b/last_commit.txt @@ -1,32 +1,34 @@ -Repository: plone.batching +Repository: plone.app.folder Branch: refs/heads/master -Date: 2018-09-22T13:28:13+02:00 +Date: 2018-09-22T17:56:45+02:00 Author: ale-rt (ale-rt) -Commit: https://github.com/plone/plone.batching/commit/80ae9eb2f1ea607f5a788477f0943c33ea3c511e +Commit: https://github.com/plone/plone.app.folder/commit/0a5bbdd324f0841d44f5f8c79d1321e5e56e5dc0 -Add a test that shows the different behavior in Python 2.7 and Python 3.6 +Fix missing ``dict.has_key`` in Python3 Files changed: -M plone/batching/tests.py +M CHANGES.rst +M src/plone/app/folder/migration.py -b"diff --git a/plone/batching/tests.py b/plone/batching/tests.py\nindex 9de14ef..f948753 100644\n--- a/plone/batching/tests.py\n+++ b/plone/batching/tests.py\n@@ -12,6 +12,7 @@\n from plone.batching.utils import opt\n from zope.component.testing import setUp\n from zope.component.testing import tearDown\n+\n import doctest\n import unittest\n \n@@ -71,6 +72,43 @@ def test_previous_first(self):\n batch = BaseBatch(range(20), 5)\n self.assertFalse(batch.previous)\n \n+ def test_navlist_no_pagerange(self):\n+ # Well, actually with a default pagerange (7)\n+ # greater than the number of pages: all pages should be displayed\n+\n+ for start in range(20):\n+ batch = BaseBatch(range(20), 5, start)\n+ self.assertListEqual(list(batch.navlist), [1, 2, 3, 4])\n+\n+ def test_navlist_with_pagerange(self):\n+ # Until we reach page 3 we have 3 pages centered on 2\n+ for start in range(0, 10):\n+ batch = BaseBatch(range(20), 5, start, pagerange=3)\n+ self.assertListEqual(\n+ list(batch.navlist),\n+ [1, 2, 3],\n+ 'Failing when starting at {}'.format(start)\n+ )\n+\n+ # then we have 3 pages centered on page 3\n+ for start in range(10, 15):\n+ batch = BaseBatch(range(20), 5, start, pagerange=3)\n+ self.assertListEqual(\n+ list(batch.navlist),\n+ [2, 3, 4],\n+ 'Failing when starting at {}'.format(start)\n+ )\n+\n+ # XXX I consider this an errorm it should be [2, 3, 4]\n+ # when we are at the last page we have two pages starting at 3\n+ for start in range(15, 20):\n+ batch = BaseBatch(range(20), 5, start, pagerange=3)\n+ self.assertListEqual(\n+ list(batch.navlist),\n+ [3, 4],\n+ 'Failing when starting at {}'.format(start)\n+ )\n+\n def test_previous(self):\n batch = BaseBatch(range(20), 5, 5)\n prev = batch.previous\n" +b"diff --git a/CHANGES.rst b/CHANGES.rst\nindex 13e9d3c..80fa6e8 100644\n--- a/CHANGES.rst\n+++ b/CHANGES.rst\n@@ -14,6 +14,9 @@ New features:\n \n Bug fixes:\n \n+- Fix missing ``dict.has_key`` in Python3\n+ [ale-rt]\n+\n - Fix GopipIndex for py3\n [pbauer]\n \ndiff --git a/src/plone/app/folder/migration.py b/src/plone/app/folder/migration.py\nindex b80ccf0..43ec285 100644\n--- a/src/plone/app/folder/migration.py\n+++ b/src/plone/app/folder/migration.py\n@@ -1,15 +1,16 @@\n # -*- coding: utf-8 -*-\n from Acquisition import aq_base\n-from Products.BTreeFolder2.BTreeFolder2 import BTreeFolder2Base as BTreeFolder\n-from Products.Five.browser import BrowserView\n from logging import getLogger\n from plone.app.folder.utils import checkpointIterator\n from plone.app.folder.utils import findObjects\n from plone.app.folder.utils import timer\n+from Products.BTreeFolder2.BTreeFolder2 import BTreeFolder2Base as BTreeFolder\n+from Products.Five.browser import BrowserView\n from time import clock\n from time import strftime\n from transaction import get\n \n+\n logger = getLogger(__name__)\n \n \n@@ -36,7 +37,10 @@ def migrate(self, folder):\n folder = aq_base(folder)\n assert isinstance(folder, BTreeFolder)\n assert folder.getId() # make sure the object is properly loaded\n- has = folder.__dict__.has_key\n+\n+ def has(key):\n+ return key in folder.__dict__\n+\n if has('_tree') and not has('_objects'):\n return False # already migrated...\n folder._initBTrees() # create _tree, _count, _mt_index\n" -Repository: plone.batching +Repository: plone.app.folder Branch: refs/heads/master -Date: 2018-09-22T14:26:00+02:00 +Date: 2018-09-22T19:30:56+02:00 Author: Alessandro Pisa (ale-rt) -Commit: https://github.com/plone/plone.batching/commit/172cb63a399c3a36f6f9ad5282ed7f3e4cdda86e +Commit: https://github.com/plone/plone.app.folder/commit/038fca70389e1c6d6af19a2ae0a151580b5f5cf5 -Merge pull request #22 from plone/21-fix-navlist +Merge pull request #18 from plone/python3 -Add a test that shows the different behavior in Python 2.7 and Python… +Fix missing ``dict.has_key`` in Python3 Files changed: -M plone/batching/tests.py +M CHANGES.rst +M src/plone/app/folder/migration.py -b"diff --git a/plone/batching/tests.py b/plone/batching/tests.py\nindex 9de14ef..f948753 100644\n--- a/plone/batching/tests.py\n+++ b/plone/batching/tests.py\n@@ -12,6 +12,7 @@\n from plone.batching.utils import opt\n from zope.component.testing import setUp\n from zope.component.testing import tearDown\n+\n import doctest\n import unittest\n \n@@ -71,6 +72,43 @@ def test_previous_first(self):\n batch = BaseBatch(range(20), 5)\n self.assertFalse(batch.previous)\n \n+ def test_navlist_no_pagerange(self):\n+ # Well, actually with a default pagerange (7)\n+ # greater than the number of pages: all pages should be displayed\n+\n+ for start in range(20):\n+ batch = BaseBatch(range(20), 5, start)\n+ self.assertListEqual(list(batch.navlist), [1, 2, 3, 4])\n+\n+ def test_navlist_with_pagerange(self):\n+ # Until we reach page 3 we have 3 pages centered on 2\n+ for start in range(0, 10):\n+ batch = BaseBatch(range(20), 5, start, pagerange=3)\n+ self.assertListEqual(\n+ list(batch.navlist),\n+ [1, 2, 3],\n+ 'Failing when starting at {}'.format(start)\n+ )\n+\n+ # then we have 3 pages centered on page 3\n+ for start in range(10, 15):\n+ batch = BaseBatch(range(20), 5, start, pagerange=3)\n+ self.assertListEqual(\n+ list(batch.navlist),\n+ [2, 3, 4],\n+ 'Failing when starting at {}'.format(start)\n+ )\n+\n+ # XXX I consider this an errorm it should be [2, 3, 4]\n+ # when we are at the last page we have two pages starting at 3\n+ for start in range(15, 20):\n+ batch = BaseBatch(range(20), 5, start, pagerange=3)\n+ self.assertListEqual(\n+ list(batch.navlist),\n+ [3, 4],\n+ 'Failing when starting at {}'.format(start)\n+ )\n+\n def test_previous(self):\n batch = BaseBatch(range(20), 5, 5)\n prev = batch.previous\n" +b"diff --git a/CHANGES.rst b/CHANGES.rst\nindex 13e9d3c..80fa6e8 100644\n--- a/CHANGES.rst\n+++ b/CHANGES.rst\n@@ -14,6 +14,9 @@ New features:\n \n Bug fixes:\n \n+- Fix missing ``dict.has_key`` in Python3\n+ [ale-rt]\n+\n - Fix GopipIndex for py3\n [pbauer]\n \ndiff --git a/src/plone/app/folder/migration.py b/src/plone/app/folder/migration.py\nindex b80ccf0..43ec285 100644\n--- a/src/plone/app/folder/migration.py\n+++ b/src/plone/app/folder/migration.py\n@@ -1,15 +1,16 @@\n # -*- coding: utf-8 -*-\n from Acquisition import aq_base\n-from Products.BTreeFolder2.BTreeFolder2 import BTreeFolder2Base as BTreeFolder\n-from Products.Five.browser import BrowserView\n from logging import getLogger\n from plone.app.folder.utils import checkpointIterator\n from plone.app.folder.utils import findObjects\n from plone.app.folder.utils import timer\n+from Products.BTreeFolder2.BTreeFolder2 import BTreeFolder2Base as BTreeFolder\n+from Products.Five.browser import BrowserView\n from time import clock\n from time import strftime\n from transaction import get\n \n+\n logger = getLogger(__name__)\n \n \n@@ -36,7 +37,10 @@ def migrate(self, folder):\n folder = aq_base(folder)\n assert isinstance(folder, BTreeFolder)\n assert folder.getId() # make sure the object is properly loaded\n- has = folder.__dict__.has_key\n+\n+ def has(key):\n+ return key in folder.__dict__\n+\n if has('_tree') and not has('_objects'):\n return False # already migrated...\n folder._initBTrees() # create _tree, _count, _mt_index\n"