Commit 38fb9e20 authored by Yusei Tahara's avatar Yusei Tahara

Add cell_getter_method property to make matrixbox field usable without XMLMatrix class.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@28664 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent b27e292e
......@@ -56,9 +56,10 @@ class MatrixBoxWidget(Widget.Widget):
"""
property_names = Widget.Widget.property_names +\
['cell_base_id', 'cell_portal_type',
'lines', 'columns', 'tabs', 'getter_method' ,
'lines', 'columns', 'tabs', 'getter_method',
'cell_getter_method',
'editable_attributes' , 'global_attributes',
'update_cell_range'
'update_cell_range',
]
default = fields.TextAreaField('default',
......@@ -121,6 +122,16 @@ class MatrixBoxWidget(Widget.Widget):
default='',
required=0)
cell_getter_method = fields.StringField('cell_getter_method',
title='Cell Getter method',
description=("""
You can specify a method in order to retrieve cells. This field can
be empty, if so the MatrixBox will use the default method : getCell.
"""),
default='',
required=0)
new_cell_method = fields.MethodField('new_cell_method',
title='New Cell method',
description=("""
......@@ -193,6 +204,10 @@ class MatrixBoxWidget(Widget.Widget):
context = getattr(here,getter_method_id)()
if context is None:
return ''
cell_getter_method_id = field.get_value('cell_getter_method')
if cell_getter_method_id not in (None, ''):
cell_getter_method = getattr(here, cell_getter_method_id)
else:
cell_getter_method = context.getCell
editable_attributes = field.get_value('editable_attributes')
......@@ -387,6 +402,10 @@ class MatrixBoxValidator(Validator.Validator):
if getter_method_id not in (None,''):
context = getattr(here,getter_method_id)()
if context is None: return {}
cell_getter_method_id = field.get_value('cell_getter_method')
if cell_getter_method_id not in (None, ''):
cell_getter_method = getattr(here, cell_getter_method_id)
else:
cell_getter_method = context.getCell
# This is required when we have no tabs
......
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