diff --git a/last_commit.txt b/last_commit.txt index 7f4924d372..5e4c5b2970 100644 --- a/last_commit.txt +++ b/last_commit.txt @@ -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) -Commit: https://github.com/plone/plone.app.upgrade/commit/44517d22edd9251ac7f1d0964c6ce955874bae1a +Date: 2019-09-03T13:12:12+02:00 +Author: Jens W. Klein (jensens) +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 \n \n \n \n- \n-\n +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'