Commit 72b3dc97 authored by Levin Zimmermann's avatar Levin Zimmermann

erp5_wendelin: Fix consistency checks on Data Bucket Stream

This fixes the following error:

  >>> data_bucket_stream = context.data_stream_module.newContent(
  >>>   portal_type = "Data Bucket Stream"
  >>> )
  >>> data_bucket_stream.insertBucket(1, 'testBucket')
  >>> data_bucket_stream.Base_getConsistencyList()

  # Error Type: AttributeError
  # Error Value: 'NoneType' object has no attribute 'getPortalType'

The returned empty lists are valid return values as it can be seen in the Folder class methods:

https://lab.nexedi.com/nexedi/erp5/blob/a17bb910/product/ERP5Type/Core/Folder.py#L1530
https://lab.nexedi.com/nexedi/erp5/blob/a17bb910/product/ERP5Type/Core/Folder.py#L1026
parent 13800642
...@@ -138,7 +138,17 @@ class DataBucketStream(Document): ...@@ -138,7 +138,17 @@ class DataBucketStream(Document):
def __len__(self): def __len__(self):
return len(self._tree) return len(self._tree)
# XXX: Workaround to fix errors during consistency checks.
# We should rename the "_tree" attribute add a migration
# script for existing instances. Then we can remove
# the following two methods.
def objectValues(self, *args, **kw):
return []
def objectIds(self, *args, **kw):
return []
def initBucketTree(self): def initBucketTree(self):
""" """
Initialize the Bucket Tree Initialize the Bucket Tree
...@@ -159,7 +169,7 @@ class DataBucketStream(Document): ...@@ -159,7 +169,7 @@ class DataBucketStream(Document):
return self._tree.maxKey(key) return self._tree.maxKey(key)
except ValueError: except ValueError:
return None return None
def getMaxIndex(self, index=None): def getMaxIndex(self, index=None):
""" """
Return the maximum index Return the maximum index
...@@ -186,11 +196,10 @@ class DataBucketStream(Document): ...@@ -186,11 +196,10 @@ class DataBucketStream(Document):
return self._long_index_tree.minKey(index) return self._long_index_tree.minKey(index)
except ValueError: except ValueError:
return None return None
def _getOb(self, id, *args, **kw): def _getOb(self, id, *args, **kw):
return None return None
def getBucketByKey(self, key=None): def getBucketByKey(self, key=None):
""" """
Get one bucket Get one bucket
...@@ -406,7 +415,7 @@ class DataBucketStream(Document): ...@@ -406,7 +415,7 @@ class DataBucketStream(Document):
key = self._long_index_tree[index] key = self._long_index_tree[index]
del self._tree[key] del self._tree[key]
del self._long_index_tree[index] del self._long_index_tree[index]
def rebuildIndexTreeByKeyOrder(self): def rebuildIndexTreeByKeyOrder(self):
""" """
Clear and rebuild the index tree by order of keys Clear and rebuild the index tree by order of keys
......
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