Commit ee4470e3 authored by Romain Courteaud's avatar Romain Courteaud

Raise a more verbose error when _asCellRange script is not found.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@3412 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent c73a1d3a
...@@ -322,15 +322,16 @@ class XMLMatrix(Folder): ...@@ -322,15 +322,16 @@ class XMLMatrix(Folder):
self._setCellRange(*kw, **kwd) self._setCellRange(*kw, **kwd)
self.reindexObject() self.reindexObject()
security.declareProtected(Permissions.ModifyPortalContent, 'updateCellRange') security.declareProtected(Permissions.ModifyPortalContent,
'updateCellRange')
def updateCellRange(self, base_id,script_id=None): def updateCellRange(self, base_id,script_id=None):
""" """
The asCellRange script if PT dependent The asCellRange script if PT dependent
whoch is not the case with this kind of code whoch is not the case with this kind of code
a better implementation consists in defining asCellRange as a generic method a better implementation consists in defining asCellRange as a
at matrix level (OverridableMethod(portal_type)) generic method at matrix level (OverridableMethod(portal_type))
which lookuops for scipt in class, meta_type and PT which lookuops for scipt in class, meta_type and PT form
form interaction could be implemented with interaction workflow interaction could be implemented with interaction workflow
this method should be renamed updateCellRange or updateMatrixCellRange this method should be renamed updateCellRange or updateMatrixCellRange
base_id is parameter of updateCellRange base_id is parameter of updateCellRange
...@@ -340,12 +341,19 @@ class XMLMatrix(Folder): ...@@ -340,12 +341,19 @@ class XMLMatrix(Folder):
if script_id is not None: if script_id is not None:
script = getattr(self, script_id) script = getattr(self, script_id)
else: else:
for script_name_begin in [self.getPortalType(), self.getMetaType(), self.__class__.__name__]: for script_name_begin in [self.getPortalType(), self.getMetaType(),
script_name = join( [ replace(script_name_begin, ' ','') , script_name_end ], '') self.__class__.__name__]:
script_name = join([replace(script_name_begin, ' ', ''),
script_name_end], '')
if hasattr(self, script_name): if hasattr(self, script_name):
script = getattr(self, script_name) script = getattr(self, script_name)
break break
cell_range = script(matrixbox=0) try:
cell_range = script(matrixbox=0)
except UnboundLocalError:
raise UnboundLocalError,\
"Did not find cell range script for portal type: %r" %\
self.getPortalType()
self.setCellRange(base_id=base_id, *cell_range) self.setCellRange(base_id=base_id, *cell_range)
......
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