-
-
Notifications
You must be signed in to change notification settings - Fork 76
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: 2019-09-03T13:12:12+02:00 Author: Jens W. Klein (jensens) <jk@kleinundpartner.at> Commit: plone/plone.folder@f20059a Implement a simplified and fast traverse: use it in GOPIP. Files changed: A news/14.bugfix M src/plone/folder/nogopip.py Repository: plone.folder Branch: refs/heads/master Date: 2019-09-03T16:04:26+02:00 Author: agitator (agitator) <agitator@users.noreply.github.com> Commit: plone/plone.folder@b08307a Merge pull request #14 from plone/traversal-performance Implement a simplified and fast traverse: use it in GOPIP. Files changed: A news/14.bugfix M src/plone/folder/nogopip.py
- Loading branch information
Showing
1 changed file
with
26 additions
and
7 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,15 +1,34 @@ | ||
Repository: plone.app.upgrade | ||
Repository: plone.folder | ||
|
||
|
||
Branch: refs/heads/master | ||
Date: 2019-09-03T09:19:55-04:00 | ||
Author: esteele (esteele) <eric@esteele.net> | ||
Commit: https://github.com/plone/plone.app.upgrade/commit/44517d22edd9251ac7f1d0964c6ce955874bae1a | ||
Date: 2019-09-03T13:12:12+02:00 | ||
Author: Jens W. Klein (jensens) <jk@kleinundpartner.at> | ||
Commit: https://github.com/plone/plone.folder/commit/f20059a3155ba480cd3d00dbc495c85ad49876da | ||
|
||
Add empty profile for 5.1.6 | ||
Implement a simplified and fast traverse: use it in GOPIP. | ||
|
||
Files changed: | ||
M plone/app/upgrade/v51/configure.zcml | ||
A news/14.bugfix | ||
M src/plone/folder/nogopip.py | ||
|
||
b'diff --git a/plone/app/upgrade/v51/configure.zcml b/plone/app/upgrade/v51/configure.zcml\nindex 010bfef6..9e467571 100644\n--- a/plone/app/upgrade/v51/configure.zcml\n+++ b/plone/app/upgrade/v51/configure.zcml\n@@ -277,16 +277,10 @@ Add image scaling options to image handling control panel.\n </gs:upgradeSteps>\n \n <gs:upgradeSteps\n- source="5114"\n- destination="5115"\n+ source="5115"\n+ destination="5116"\n profile="Products.CMFPlone:plone">\n \n- <gs:upgradeDepends\n- title="Run to515 upgrade profile."\n- description="Update resources for Datatables"\n- import_profile="plone.app.upgrade.v51:to515"\n- />\n-\n <gs:upgradeStep\n title="Miscellaneous"\n description=""\n' | ||
b'diff --git a/news/14.bugfix b/news/14.bugfix\nnew file mode 100644\nindex 0000000..afffd23\n--- /dev/null\n+++ b/news/14.bugfix\n@@ -0,0 +1,4 @@\n+- Fixes slow lookup of ``documentToKeyMap`` in GopipIndex.\n+ About up to 66x speedup in some cases.\n+ This may add up to seconds less on large navtree renderings.\n+ [jensens]\n\\ No newline at end of file\ndiff --git a/src/plone/folder/nogopip.py b/src/plone/folder/nogopip.py\nindex 6affabf..24d6d2d 100644\n--- a/src/plone/folder/nogopip.py\n+++ b/src/plone/folder/nogopip.py\n@@ -1,17 +1,35 @@\n # -*- coding: utf-8 -*-\n from Acquisition import aq_base\n from App.special_dtml import DTMLFile\n-from OFS.SimpleItem import SimpleItem\n-from Products.CMFCore.interfaces import ISiteRoot\n-from Products.PluginIndexes.interfaces import IPluggableIndex, ISortIndex\n from inspect import currentframe\n from logging import getLogger\n+from OFS.SimpleItem import SimpleItem\n+from Products.CMFCore.interfaces import ISiteRoot\n+from Products.PluginIndexes.interfaces import IPluggableIndex\n+from Products.PluginIndexes.interfaces import ISortIndex\n from zope.component import getUtility\n from zope.interface import implementer\n \n logger = getLogger(__name__)\n \n \n+def traverse(base, path):\n+ """simplified fast unrestricted traverse.\n+ base: the app-root to start from\n+ path: absolute path from app root as string\n+ returns: content at the end or None\n+ """\n+ current = base\n+ for cid in path.split(\'/\'):\n+ if not cid:\n+ continue\n+ try:\n+ current = current[cid]\n+ except KeyError:\n+ return None\n+ return current\n+\n+\n @implementer(IPluggableIndex)\n class StubIndex(SimpleItem):\n """ stub catalog index doing nothing """\n@@ -74,13 +92,13 @@ def documentToKeyMap(self):\n items = []\n containers = {}\n getpath = self.catalog.paths.get\n- traverse = getUtility(ISiteRoot).unrestrictedTraverse\n+ root = getUtility(ISiteRoot).getPhysicalRoot()\n for rid in rs:\n path = getpath(rid)\n parent, id = path.rsplit(\'/\', 1)\n container = containers.get(parent)\n if container is None:\n- containers[parent] = container = traverse(parent)\n+ containers[parent] = container = traverse(root, parent)\n rids[id] = rid # remember in case of single folder\n items.append((rid, container, id)) # or else for deferred lookup\n pos = {}\n@@ -97,22 +115,26 @@ def documentToKeyMap(self):\n if rid:\n pos[rid] = idx\n return pos\n- else:\n- # otherwise the entire map needs to be constructed...\n- for rid, container, id in items:\n- if getattr(aq_base(container), \'getObjectPosition\', None):\n- pos[rid] = container.getObjectPosition(id)\n- else:\n- # fallback for unordered folders\n- pos[rid] = 0\n- return pos\n+ # otherwise the entire map needs to be constructed...\n+ for rid, container, id in items:\n+ if getattr(aq_base(container), \'getObjectPosition\', None):\n+ pos[rid] = container.getObjectPosition(id)\n+ else:\n+ # fallback for unordered folders\n+ pos[rid] = 0\n+ return pos\n \n \n manage_addGopipForm = DTMLFile(\'dtml/addGopipIndex\', globals())\n \n \n-def manage_addGopipIndex(self, identifier, REQUEST=None, RESPONSE=None,\n- URL3=None):\n+def manage_addGopipIndex(\n+ self,\n+ identifier,\n+ REQUEST=None,\n+ RESPONSE=None,\n+ URL3=None\n+):\n """ add a fake gopip index """\n return self.manage_addIndex(\n identifier,\n' | ||
|
||
Repository: plone.folder | ||
|
||
|
||
Branch: refs/heads/master | ||
Date: 2019-09-03T16:04:26+02:00 | ||
Author: agitator (agitator) <agitator@users.noreply.github.com> | ||
Commit: https://github.com/plone/plone.folder/commit/b08307a87883d70ff509eefb33dee4d91a2abfec | ||
|
||
Merge pull request #14 from plone/traversal-performance | ||
|
||
Implement a simplified and fast traverse: use it in GOPIP. | ||
|
||
Files changed: | ||
A news/14.bugfix | ||
M src/plone/folder/nogopip.py | ||
|
||
b'diff --git a/news/14.bugfix b/news/14.bugfix\nnew file mode 100644\nindex 0000000..afffd23\n--- /dev/null\n+++ b/news/14.bugfix\n@@ -0,0 +1,4 @@\n+- Fixes slow lookup of ``documentToKeyMap`` in GopipIndex.\n+ About up to 66x speedup in some cases.\n+ This may add up to seconds less on large navtree renderings.\n+ [jensens]\n\\ No newline at end of file\ndiff --git a/src/plone/folder/nogopip.py b/src/plone/folder/nogopip.py\nindex 6affabf..24d6d2d 100644\n--- a/src/plone/folder/nogopip.py\n+++ b/src/plone/folder/nogopip.py\n@@ -1,17 +1,35 @@\n # -*- coding: utf-8 -*-\n from Acquisition import aq_base\n from App.special_dtml import DTMLFile\n-from OFS.SimpleItem import SimpleItem\n-from Products.CMFCore.interfaces import ISiteRoot\n-from Products.PluginIndexes.interfaces import IPluggableIndex, ISortIndex\n from inspect import currentframe\n from logging import getLogger\n+from OFS.SimpleItem import SimpleItem\n+from Products.CMFCore.interfaces import ISiteRoot\n+from Products.PluginIndexes.interfaces import IPluggableIndex\n+from Products.PluginIndexes.interfaces import ISortIndex\n from zope.component import getUtility\n from zope.interface import implementer\n \n logger = getLogger(__name__)\n \n \n+def traverse(base, path):\n+ """simplified fast unrestricted traverse.\n+ base: the app-root to start from\n+ path: absolute path from app root as string\n+ returns: content at the end or None\n+ """\n+ current = base\n+ for cid in path.split(\'/\'):\n+ if not cid:\n+ continue\n+ try:\n+ current = current[cid]\n+ except KeyError:\n+ return None\n+ return current\n+\n+\n @implementer(IPluggableIndex)\n class StubIndex(SimpleItem):\n """ stub catalog index doing nothing """\n@@ -74,13 +92,13 @@ def documentToKeyMap(self):\n items = []\n containers = {}\n getpath = self.catalog.paths.get\n- traverse = getUtility(ISiteRoot).unrestrictedTraverse\n+ root = getUtility(ISiteRoot).getPhysicalRoot()\n for rid in rs:\n path = getpath(rid)\n parent, id = path.rsplit(\'/\', 1)\n container = containers.get(parent)\n if container is None:\n- containers[parent] = container = traverse(parent)\n+ containers[parent] = container = traverse(root, parent)\n rids[id] = rid # remember in case of single folder\n items.append((rid, container, id)) # or else for deferred lookup\n pos = {}\n@@ -97,22 +115,26 @@ def documentToKeyMap(self):\n if rid:\n pos[rid] = idx\n return pos\n- else:\n- # otherwise the entire map needs to be constructed...\n- for rid, container, id in items:\n- if getattr(aq_base(container), \'getObjectPosition\', None):\n- pos[rid] = container.getObjectPosition(id)\n- else:\n- # fallback for unordered folders\n- pos[rid] = 0\n- return pos\n+ # otherwise the entire map needs to be constructed...\n+ for rid, container, id in items:\n+ if getattr(aq_base(container), \'getObjectPosition\', None):\n+ pos[rid] = container.getObjectPosition(id)\n+ else:\n+ # fallback for unordered folders\n+ pos[rid] = 0\n+ return pos\n \n \n manage_addGopipForm = DTMLFile(\'dtml/addGopipIndex\', globals())\n \n \n-def manage_addGopipIndex(self, identifier, REQUEST=None, RESPONSE=None,\n- URL3=None):\n+def manage_addGopipIndex(\n+ self,\n+ identifier,\n+ REQUEST=None,\n+ RESPONSE=None,\n+ URL3=None\n+):\n """ add a fake gopip index """\n return self.manage_addIndex(\n identifier,\n' | ||
|