[Checkins] SVN: Products.BTreeFolder2/trunk/ Changed the `objectIds`, `objectItems` and `objectValues` methods to use the internal OOBTree methods directly if no `spec` argument is passed.
Hanno Schlichting
hannosch at hannosch.eu
Sun Jul 11 08:51:16 EDT 2010
Log message for revision 114591:
Changed the `objectIds`, `objectItems` and `objectValues` methods to use the internal OOBTree methods directly if no `spec` argument is passed.
Changed:
U Products.BTreeFolder2/trunk/CHANGES.txt
U Products.BTreeFolder2/trunk/src/Products/BTreeFolder2/BTreeFolder2.py
U Products.BTreeFolder2/trunk/src/Products/BTreeFolder2/tests/testBTreeFolder2.py
-=-
Modified: Products.BTreeFolder2/trunk/CHANGES.txt
===================================================================
--- Products.BTreeFolder2/trunk/CHANGES.txt 2010-07-11 12:47:04 UTC (rev 114590)
+++ Products.BTreeFolder2/trunk/CHANGES.txt 2010-07-11 12:51:16 UTC (rev 114591)
@@ -4,6 +4,9 @@
2.13.0 (unreleased)
-------------------
+- Changed the `objectIds`, `objectItems` and `objectValues` methods to use the
+ internal OOBTree methods directly if no `spec` argument is passed.
+
- Change implementation of `keys`, `items` and `values` method to access the
`self._tree` OOBTree methods directly. This avoids lookups in the meta_types
structures.
Modified: Products.BTreeFolder2/trunk/src/Products/BTreeFolder2/BTreeFolder2.py
===================================================================
--- Products.BTreeFolder2/trunk/src/Products/BTreeFolder2/BTreeFolder2.py 2010-07-11 12:47:04 UTC (rev 114590)
+++ Products.BTreeFolder2/trunk/src/Products/BTreeFolder2/BTreeFolder2.py 2010-07-11 12:51:16 UTC (rev 114591)
@@ -329,13 +329,14 @@
# If 'spec' is specified, returns objects whose meta_type
# matches 'spec'.
- mti = self._mt_index
if spec is None:
- spec = mti.keys() #all meta types
+ return self.keys()
if isinstance(spec, str):
spec = [spec]
+
set = None
+ mti = self._mt_index
for meta_type in spec:
ids = mti.get(meta_type, None)
if ids is not None:
@@ -360,6 +361,8 @@
# Returns a list of actual subobjects of the current object.
# If 'spec' is specified, returns only objects whose meta_type
# match 'spec'.
+ if spec is None:
+ return self.values()
return LazyMap(self._getOb, self.objectIds(spec))
security.declareProtected(access_contents_information, 'values')
@@ -371,6 +374,8 @@
# Returns a list of (id, subobject) tuples of the current object.
# If 'spec' is specified, returns only objects whose meta_type match
# 'spec'
+ if spec is None:
+ return self.items()
return LazyMap(lambda id, _getOb=self._getOb: (id, _getOb(id)),
self.objectIds(spec))
Modified: Products.BTreeFolder2/trunk/src/Products/BTreeFolder2/tests/testBTreeFolder2.py
===================================================================
--- Products.BTreeFolder2/trunk/src/Products/BTreeFolder2/tests/testBTreeFolder2.py 2010-07-11 12:47:04 UTC (rev 114590)
+++ Products.BTreeFolder2/trunk/src/Products/BTreeFolder2/tests/testBTreeFolder2.py 2010-07-11 12:51:16 UTC (rev 114591)
@@ -73,8 +73,7 @@
values = self.f.objectValues()
self.assertEqual(len(values), 1)
self.assertEqual(values[0].id, 'item')
- # Make sure the object is wrapped.
- self.assert_(values[0] is not self.getBase(values[0]))
+ self.assert_(values[0] is self.getBase(values[0]))
def testObjectItems(self):
items = self.f.objectItems()
@@ -82,8 +81,7 @@
id, val = items[0]
self.assertEqual(id, 'item')
self.assertEqual(val.id, 'item')
- # Make sure the object is wrapped.
- self.assert_(val is not self.getBase(val))
+ self.assert_(val is self.getBase(val))
def testHasKey(self):
self.assert_(self.f.hasObject('item')) # Old spelling
More information about the checkins
mailing list