[Zope-CVS] CVS: Products/BTreeFolder2 - BTreeFolder2.py:1.18
Shane Hathaway
shane at zope.com
Mon Dec 29 18:27:35 EST 2003
Update of /cvs-repository/Products/BTreeFolder2
In directory cvs.zope.org:/tmp/cvs-serv10395
Modified Files:
BTreeFolder2.py
Log Message:
Refactored: most of _populateFromFolder() was equivalent to _setOb().
Also allowed no id in the constructor.
=== Products/BTreeFolder2/BTreeFolder2.py 1.17 => 1.18 ===
--- Products/BTreeFolder2/BTreeFolder2.py:1.17 Wed Dec 10 12:03:38 2003
+++ Products/BTreeFolder2/BTreeFolder2.py Mon Dec 29 18:27:34 2003
@@ -90,8 +90,9 @@
title = ''
- def __init__(self, id):
- self.id = id
+ def __init__(self, id=None):
+ if id is not None:
+ self.id = id
self._tree = OOBTree()
self._count = Length()
self._mt_index = OOBTree()
@@ -100,28 +101,10 @@
def _populateFromFolder(self, source):
"""Fill this folder with the contents of another folder.
"""
- ids = source.objectIds()
- tree = self._tree
- count = self._count
- mti = self._mt_index
- for name in ids:
+ for name in source.objectIds():
value = source._getOb(name, None)
if value is not None:
- if tree.has_key(name):
- raise KeyError, (
- 'There is already an item named "%s".'
- % name)
- tree[name] = aq_base(value)
- count.change(1)
- # Update the meta type index.
- meta_type = getattr(value, 'meta_type', None)
- if meta_type is None:
- continue
- ids = mti.get(meta_type, None)
- if ids is None:
- ids = OIBTree()
- mti[meta_type] = ids
- ids[name] = 1
+ self._setOb(name, aq_base(value))
security.declareProtected(view_management_screens, 'manage_cleanup')
@@ -209,7 +192,7 @@
"""
tree = self._tree
if tree.has_key(id):
- raise KeyError, 'There is already an item named "%s".' % id
+ raise KeyError('There is already an item named "%s".' % id)
tree[id] = object
self._count.change(1)
# Update the meta type index.
More information about the Zope-CVS
mailing list