Commit 0914b6a0 authored by Jérome Perrin's avatar Jérome Perrin

It makes no sense to define a sort order in the matrix, this feature is theref

ore removed.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@5120 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent baecf725
...@@ -59,36 +59,12 @@ class PredicateMatrix(XMLMatrix): ...@@ -59,36 +59,12 @@ class PredicateMatrix(XMLMatrix):
, PropertySheet.DublinCore , PropertySheet.DublinCore
) )
def _getSortedCellKeyList(self):
"""
Return the list of cell keys, sorted according to int_index
property on Predicates.
TODO: cache.
"""
total_priorities = {} # a dictionnary giving sum of int_index for a
# coordinate.
cell_key_list = list(self.getCellKeyList(
base_id = self.predicate_matrix_base_id ))
for coord_list in cell_key_list :
priority = 0
for coord in coord_list :
predicate = self.unrestrictedTraverse(coord, None)
if predicate is not None:
priority += predicate.getIntIndex()
total_priorities[tuple(coord_list)] = priority
cell_key_list.sort(lambda c1, c2:
cmp(total_priorities[tuple(c1)],
total_priorities[tuple(c2)]))
return cell_key_list
def _getMatchingCell(self, movement): def _getMatchingCell(self, movement):
""" """
Browse all cells and test them until match found Browse all cells and test them until match found
""" """
for cell_key in self._getSortedCellKeyList() : for cell in self.getCellValueList(
if self.hasCell(base_id=self.predicate_matrix_base_id, *cell_key) : base_id=self.predicate_matrix_base_id) :
cell = self.getCell(base_id=self.predicate_matrix_base_id, *cell_key)
if cell.test(movement): if cell.test(movement):
return cell return cell
return None return 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