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): ...@@ -56,9 +56,10 @@ class MatrixBoxWidget(Widget.Widget):
""" """
property_names = Widget.Widget.property_names +\ property_names = Widget.Widget.property_names +\
['cell_base_id', 'cell_portal_type', ['cell_base_id', 'cell_portal_type',
'lines', 'columns', 'tabs', 'getter_method' , 'lines', 'columns', 'tabs', 'getter_method',
'cell_getter_method',
'editable_attributes' , 'global_attributes', 'editable_attributes' , 'global_attributes',
'update_cell_range' 'update_cell_range',
] ]
default = fields.TextAreaField('default', default = fields.TextAreaField('default',
...@@ -121,6 +122,16 @@ class MatrixBoxWidget(Widget.Widget): ...@@ -121,6 +122,16 @@ class MatrixBoxWidget(Widget.Widget):
default='', default='',
required=0) 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', new_cell_method = fields.MethodField('new_cell_method',
title='New Cell method', title='New Cell method',
description=(""" description=("""
...@@ -193,7 +204,11 @@ class MatrixBoxWidget(Widget.Widget): ...@@ -193,7 +204,11 @@ class MatrixBoxWidget(Widget.Widget):
context = getattr(here,getter_method_id)() context = getattr(here,getter_method_id)()
if context is None: if context is None:
return '' return ''
cell_getter_method = context.getCell 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') editable_attributes = field.get_value('editable_attributes')
# This is required when we have no tabs # This is required when we have no tabs
...@@ -387,7 +402,11 @@ class MatrixBoxValidator(Validator.Validator): ...@@ -387,7 +402,11 @@ class MatrixBoxValidator(Validator.Validator):
if getter_method_id not in (None,''): if getter_method_id not in (None,''):
context = getattr(here,getter_method_id)() context = getattr(here,getter_method_id)()
if context is None: return {} if context is None: return {}
cell_getter_method = context.getCell 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 # This is required when we have no tabs
if len(tabs) == 0: tabs = [(None,None)] if len(tabs) == 0: tabs = [(None,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