Commit ca080e76 authored by Vincent Pelletier's avatar Vincent Pelletier Committed by Tatuya Kamada

ERP5Type.Core.Folder: Expose BTree-style iteritems.

parent 9b498797
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
import transaction import transaction
from collections import deque from collections import deque
from AccessControl import ClassSecurityInfo, getSecurityManager from AccessControl import ClassSecurityInfo, getSecurityManager
from AccessControl.ZopeGuards import NullIter
from Acquisition import aq_base, aq_parent, aq_inner from Acquisition import aq_base, aq_parent, aq_inner
from OFS.ObjectManager import ObjectManager from OFS.ObjectManager import ObjectManager
from OFS.History import Historical from OFS.History import Historical
...@@ -415,12 +416,7 @@ class FolderMixIn(ExtensionClass.Base): ...@@ -415,12 +416,7 @@ class FolderMixIn(ExtensionClass.Base):
next_id = deque(x for x in container.objectIds() if x >= next_id) next_id = deque(x for x in container.objectIds() if x >= next_id)
recurse_stack[depth] = next_id recurse_stack[depth] = next_id
else: else:
if folder_handler == HBTREE_HANDLER: for id, ob in container.iteritems(next_id):
iteritems = container._htree_iteritems
else:
iteritems = container._tree.iteritems
for id, ob in iteritems(next_id):
ob = ob.__of__(container)
if not restricted or validate(container, container, id, ob): if not restricted or validate(container, container, id, ob):
recurse_stack[depth] = id recurse_stack[depth] = id
recurse(ob, depth + 1) recurse(ob, depth + 1)
...@@ -1039,6 +1035,15 @@ class Folder(CopyContainer, CMFBTreeFolder, CMFHBTreeFolder, Base, FolderMixIn): ...@@ -1039,6 +1035,15 @@ class Folder(CopyContainer, CMFBTreeFolder, CMFHBTreeFolder, Base, FolderMixIn):
return [] return []
return CMFBTreeFolder.items(self, *args, **kw) return CMFBTreeFolder.items(self, *args, **kw)
def iteritems(self, *args, **kw):
if self._folder_handler == HBTREE_HANDLER:
result = CMFHBTreeFolder._htree_iteritems(self, *args, **kw)
else:
if self._tree is None:
return ()
result = self._tree.iteritems(*args, **kw)
return NullIter(((x, y.__of__(self)) for x, y in result))
def hasObject(self, id): def hasObject(self, id):
if self._folder_handler == HBTREE_HANDLER: if self._folder_handler == HBTREE_HANDLER:
if self._htree is None: if self._htree is None:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment