Commit 643dee1d authored by Julien Muchembled's avatar Julien Muchembled

HBTreeFolder2: minor cleanup

parent 67f9f3dc
...@@ -24,7 +24,6 @@ from App.special_dtml import DTMLFile ...@@ -24,7 +24,6 @@ from App.special_dtml import DTMLFile
from Persistence import Persistent, PersistentMapping from Persistence import Persistent, PersistentMapping
from Acquisition import aq_base from Acquisition import aq_base
from BTrees.OOBTree import OOBTree from BTrees.OOBTree import OOBTree
from BTrees.OIBTree import OIBTree, union
from BTrees.Length import Length from BTrees.Length import Length
from ZODB.POSException import ConflictError from ZODB.POSException import ConflictError
from OFS.ObjectManager import BadRequestException, BeforeDeleteException from OFS.ObjectManager import BadRequestException, BeforeDeleteException
...@@ -180,11 +179,8 @@ class HBTreeFolder2Base (Persistent): ...@@ -180,11 +179,8 @@ class HBTreeFolder2Base (Persistent):
def _populateFromFolder(self, source): def _populateFromFolder(self, source):
"""Fill this folder with the contents of another folder. """Fill this folder with the contents of another folder.
""" """
for name in source.objectIds(): for name, value in source.objectItems():
value = source._getOb(name, None) self._setOb(name, aq_base(value))
if value is not None:
self._setOb(name, aq_base(value))
security.declareProtected(view_management_screens, 'manage_fixCount') security.declareProtected(view_management_screens, 'manage_fixCount')
def manage_fixCount(self, dry_run=0): def manage_fixCount(self, dry_run=0):
...@@ -260,7 +256,7 @@ class HBTreeFolder2Base (Persistent): ...@@ -260,7 +256,7 @@ class HBTreeFolder2Base (Persistent):
error=sys.exc_info()) error=sys.exc_info())
try: try:
self._htree = OOBTree(self._htree) # XXX hFix needed self._htree = OOBTree(self._htree) # XXX hFix needed
except: except Exception:
LOG('HBTreeFolder2', ERROR, 'Failed to fix %s.' % path, LOG('HBTreeFolder2', ERROR, 'Failed to fix %s.' % path,
error=sys.exc_info()) error=sys.exc_info())
raise raise
...@@ -418,7 +414,7 @@ class HBTreeFolder2Base (Persistent): ...@@ -418,7 +414,7 @@ class HBTreeFolder2Base (Persistent):
h = self._htree h = self._htree
recurse_stack = [] recurse_stack = []
try: try:
for sub_id in min and self.hashId(min) or ('',): for sub_id in self.hashId(min) if min else ('',):
if recurse_stack: if recurse_stack:
i.next() i.next()
if type(h) is not OOBTree: if type(h) is not OOBTree:
...@@ -490,8 +486,6 @@ class HBTreeFolder2Base (Persistent): ...@@ -490,8 +486,6 @@ class HBTreeFolder2Base (Persistent):
'objectItems') 'objectItems')
def objectItems(self, base_id=_marker): def objectItems(self, base_id=_marker):
# Returns a list of (id, subobject) tuples of the current object. # Returns a list of (id, subobject) tuples of the current object.
# If 'spec' is specified, returns only objects whose meta_type match
# 'spec'
return HBTreeObjectItems(self, base_id) return HBTreeObjectItems(self, base_id)
# superValues() looks for the _objects attribute, but the implementation # superValues() looks for the _objects attribute, but the implementation
...@@ -546,7 +540,7 @@ class HBTreeFolder2Base (Persistent): ...@@ -546,7 +540,7 @@ class HBTreeFolder2Base (Persistent):
raise raise
except ConflictError: except ConflictError:
raise raise
except: except Exception:
LOG('Zope', ERROR, 'manage_beforeDelete() threw', LOG('Zope', ERROR, 'manage_beforeDelete() threw',
error=sys.exc_info()) error=sys.exc_info())
self._delOb(id) self._delOb(id)
......
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