Commit b4b92a1f authored by Vincent Pelletier's avatar Vincent Pelletier

Update Formulator rendering API (except css and odt) to make it accept a new...

Update Formulator rendering API (except css and odt) to make it accept a new "render_prefix" parameter.
Its basic purpose is similar to existing "key" parameter, but instead of replacing field id it gets prepended to it.
Its "evolved" purpose is to make it possible to distinguish multiple renderings of the *same* field (same form, same field) in a single rendering sequence (ie, in the same web page).
It's safe to just ignore it when writing a renderer.
Update all existing renderers, and monkeypatch a few more.
Ignore the new parameter in all of them except ListBox (stored on renderer instance but not used yet).


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@21998 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent bdd36dcb
...@@ -64,7 +64,7 @@ class DurationWidget(FormulatorPatch.IntegerWidget): ...@@ -64,7 +64,7 @@ class DurationWidget(FormulatorPatch.IntegerWidget):
default="", default="",
required=1) required=1)
def render_view(self, field, value, REQUEST=None): def render_view(self, field, value, REQUEST=None, render_prefix=None):
sub_field_render_list = [] sub_field_render_list = []
for title, sub_key, convertion in (('Hour', 'hour', HOUR_IN_SECOND), for title, sub_key, convertion in (('Hour', 'hour', HOUR_IN_SECOND),
('Minute', 'minute', MINUTE_IN_SECOND)): ('Minute', 'minute', MINUTE_IN_SECOND)):
...@@ -80,7 +80,7 @@ class DurationWidget(FormulatorPatch.IntegerWidget): ...@@ -80,7 +80,7 @@ class DurationWidget(FormulatorPatch.IntegerWidget):
field, value, REQUEST=REQUEST)) field, value, REQUEST=REQUEST))
return ':'.join(sub_field_render_list) return ':'.join(sub_field_render_list)
def render(self, field, key, value, REQUEST): def render(self, field, key, value, REQUEST, render_prefix=None):
sub_field_render_list = [] sub_field_render_list = []
for title, sub_key, convertion in (('Hour', 'hour', HOUR_IN_SECOND), for title, sub_key, convertion in (('Hour', 'hour', HOUR_IN_SECOND),
('Minute', 'minute', MINUTE_IN_SECOND)): ('Minute', 'minute', MINUTE_IN_SECOND)):
...@@ -97,14 +97,14 @@ class DurationWidget(FormulatorPatch.IntegerWidget): ...@@ -97,14 +97,14 @@ class DurationWidget(FormulatorPatch.IntegerWidget):
value, REQUEST, 'second')) value, REQUEST, 'second'))
return ':'.join(sub_field_render_list) return ':'.join(sub_field_render_list)
def render_sub_field_view(self, field, value, REQUEST=None): def render_sub_field_view(self, field, value, REQUEST=None, render_prefix=None):
""" """
Render dynamically a subfield Render dynamically a subfield
""" """
return FormulatorPatch.IntegerFieldWidgetInstance.render_view(field, value, return FormulatorPatch.IntegerFieldWidgetInstance.render_view(field, value,
REQUEST=REQUEST) REQUEST=REQUEST)
def render_sub_field(self, field, key, value, REQUEST, keyword): def render_sub_field(self, field, key, value, REQUEST, keyword, render_prefix=None):
""" """
Render dynamically a subfield Render dynamically a subfield
""" """
......
...@@ -72,7 +72,7 @@ class EditorWidget(Widget.TextAreaWidget): ...@@ -72,7 +72,7 @@ class EditorWidget(Widget.TextAreaWidget):
items=[('Standard Text Area', 'text_area'), items=[('Standard Text Area', 'text_area'),
('FCK Editor', 'fck_editor')]) ('FCK Editor', 'fck_editor')])
def render(self, field, key, value, REQUEST): def render(self, field, key, value, REQUEST, render_prefix=None):
""" """
Render editor Render editor
""" """
...@@ -87,7 +87,7 @@ class EditorWidget(Widget.TextAreaWidget): ...@@ -87,7 +87,7 @@ class EditorWidget(Widget.TextAreaWidget):
'inputname' : key 'inputname' : key
}) })
def render_view(self, field, value, REQUEST=None): def render_view(self, field, value, REQUEST=None, render_prefix=None):
""" """
Render form in view only mode. Render form in view only mode.
""" """
......
...@@ -86,7 +86,7 @@ class FormBoxWidget(Widget.Widget): ...@@ -86,7 +86,7 @@ class FormBoxWidget(Widget.Widget):
default="", default="",
required=0) required=0)
def render(self, field, key, value, REQUEST): def render(self, field, key, value, REQUEST, render_prefix=None):
""" """
Render a form in a field Render a form in a field
""" """
......
This diff is collapsed.
...@@ -14,7 +14,7 @@ class HyperLinkWidget(LabelWidget): ...@@ -14,7 +14,7 @@ class HyperLinkWidget(LabelWidget):
default="", default="",
required=1) required=1)
def render(self, field, key, value, REQUEST): def render(self, field, key, value, REQUEST, render_prefix=None):
return render_element("a", return render_element("a",
href=field.get_value('href'), href=field.get_value('href'),
css_class=field.get_value('css_class'), css_class=field.get_value('css_class'),
......
...@@ -66,12 +66,12 @@ class ImageFieldWidget(Widget.TextWidget): ...@@ -66,12 +66,12 @@ class ImageFieldWidget(Widget.TextWidget):
default=75, default=75,
required=0) required=0)
def render(self, field, key, value, REQUEST): def render(self, field, key, value, REQUEST, render_prefix=None):
"""Render image field as a link to the image """Render image field as a link to the image
""" """
return self.render_view(field, value, REQUEST=REQUEST) return self.render_view(field, value, REQUEST=REQUEST)
def render_view(self, field, value, REQUEST=None): def render_view(self, field, value, REQUEST=None, render_prefix=None):
"""Render image field as a link to the image """Render image field as a link to the image
""" """
# Url is already defined in value # Url is already defined in value
......
...@@ -68,7 +68,7 @@ class InputButtonWidget(Widget.Widget): ...@@ -68,7 +68,7 @@ class InputButtonWidget(Widget.Widget):
default='', default='',
required=0) required=0)
def render(self, field, key, value, REQUEST): def render(self, field, key, value, REQUEST, render_prefix=None):
"""Render input button. """Render input button.
""" """
image = field.get_value('image') image = field.get_value('image')
......
...@@ -355,14 +355,14 @@ class ListBoxWidget(Widget.Widget): ...@@ -355,14 +355,14 @@ class ListBoxWidget(Widget.Widget):
required=0) required=0)
property_names.append('page_template') property_names.append('page_template')
def render_view(self, field, value, REQUEST=None, render_format='html', key='listbox'): def render_view(self, field, value, REQUEST=None, render_format='html', key='listbox', render_prefix=None):
""" """
Render a ListBox in read-only. Render a ListBox in read-only.
""" """
if REQUEST is None: REQUEST=get_request() if REQUEST is None: REQUEST=get_request()
return self.render(field, key, value, REQUEST, render_format=render_format) return self.render(field, key, value, REQUEST, render_format=render_format)
def render(self, field, key, value, REQUEST, render_format='html'): def render(self, field, key, value, REQUEST, render_format='html', render_prefix=None):
""" """
This is where most things happen. This method renders a list This is where most things happen. This method renders a list
of items of items
...@@ -390,7 +390,7 @@ class ListBoxWidget(Widget.Widget): ...@@ -390,7 +390,7 @@ class ListBoxWidget(Widget.Widget):
if render_format == 'list': if render_format == 'list':
renderer = ListBoxListRenderer(self, field, REQUEST) renderer = ListBoxListRenderer(self, field, REQUEST)
else: else:
renderer = ListBoxHTMLRenderer(self, field, REQUEST) renderer = ListBoxHTMLRenderer(self, field, REQUEST, render_prefix=render_prefix)
return renderer() return renderer()
...@@ -417,12 +417,13 @@ class ListBoxRenderer: ...@@ -417,12 +417,13 @@ class ListBoxRenderer:
and a request object. and a request object.
""" """
def __init__(self, widget = None, field = None, REQUEST = None, **kw): def __init__(self, widget = None, field = None, REQUEST = None, render_prefix=None, **kw):
"""Store the parameters for later use. """Store the parameters for later use.
""" """
self.widget = widget self.widget = widget
self.field = field self.field = field
self.request = REQUEST self.request = REQUEST
self.render_prefix = render_prefix
def getPhysicalPath(self): def getPhysicalPath(self):
""" """
......
...@@ -175,7 +175,7 @@ class MatrixBoxWidget(Widget.Widget): ...@@ -175,7 +175,7 @@ class MatrixBoxWidget(Widget.Widget):
"The cell range should be updated upon edit."), "The cell range should be updated upon edit."),
default=0) default=0)
def render(self, field, key, value, REQUEST, render_format='html'): def render(self, field, key, value, REQUEST, render_format='html', render_prefix=None):
""" """
This is where most things happen. This method renders a list This is where most things happen. This method renders a list
of items of items
......
...@@ -35,7 +35,7 @@ class MultiLinkFieldWidget(Widget.MultiItemsWidget): ...@@ -35,7 +35,7 @@ class MultiLinkFieldWidget(Widget.MultiItemsWidget):
property_names = Widget.Widget.property_names +\ property_names = Widget.Widget.property_names +\
['items', 'view_separator', 'extra', 'extra_item'] ['items', 'view_separator', 'extra', 'extra_item']
def render_item(self, item_text, item_value, key, css_class, extra_item) : def render_item(self, item_text, item_value, key, css_class, extra_item, render_prefix=None) :
"""Render an Item.""" """Render an Item."""
return Widget.render_element('a', return Widget.render_element('a',
href=item_value, href=item_value,
...@@ -45,7 +45,7 @@ class MultiLinkFieldWidget(Widget.MultiItemsWidget): ...@@ -45,7 +45,7 @@ class MultiLinkFieldWidget(Widget.MultiItemsWidget):
extra_item = extra_item) extra_item = extra_item)
render_selected_item = render_item render_selected_item = render_item
def render(self, field, key, value, REQUEST): def render(self, field, key, value, REQUEST, render_prefix=None):
"""Render the field.""" """Render the field."""
rendered_items = self.render_items(field, key, value, REQUEST) rendered_items = self.render_items(field, key, value, REQUEST)
return field.get_value('view_separator').join(rendered_items) return field.get_value('view_separator').join(rendered_items)
......
...@@ -236,7 +236,7 @@ class MultiRelationStringFieldWidget(Widget.LinesTextAreaWidget, ...@@ -236,7 +236,7 @@ class MultiRelationStringFieldWidget(Widget.LinesTextAreaWidget,
value_list, None)] value_list, None)]
return result_list return result_list
def render(self, field, key, value, REQUEST): def render(self, field, key, value, REQUEST, render_prefix=None):
""" """
Render text input field. Render text input field.
""" """
...@@ -294,7 +294,7 @@ class MultiRelationStringFieldWidget(Widget.LinesTextAreaWidget, ...@@ -294,7 +294,7 @@ class MultiRelationStringFieldWidget(Widget.LinesTextAreaWidget,
REQUEST.set('_v_relation_field_index', relation_field_index + 1) REQUEST.set('_v_relation_field_index', relation_field_index + 1)
return html_string return html_string
def render_view(self, field, value, REQUEST=None): def render_view(self, field, value, REQUEST=None, render_prefix=None):
""" """
Render read only field. Render read only field.
...@@ -310,7 +310,7 @@ class MultiRelationStringFieldWidget(Widget.LinesTextAreaWidget, ...@@ -310,7 +310,7 @@ class MultiRelationStringFieldWidget(Widget.LinesTextAreaWidget,
return html_string return html_string
def render_wheel(self, field, value, REQUEST, relation_index=0, def render_wheel(self, field, value, REQUEST, relation_index=0,
sub_index=None): sub_index=None, render_prefix=None):
""" """
Render wheel used to display a listbox Render wheel used to display a listbox
""" """
...@@ -329,7 +329,7 @@ class MultiRelationStringFieldWidget(Widget.LinesTextAreaWidget, ...@@ -329,7 +329,7 @@ class MultiRelationStringFieldWidget(Widget.LinesTextAreaWidget,
(portal_url_string, portal_selections_url_string, (portal_url_string, portal_selections_url_string,
relation_index, sub_index_string) relation_index, sub_index_string)
def render_relation_link(self, field, value, REQUEST): def render_relation_link(self, field, value, REQUEST, render_prefix=None):
""" """
Render link to the related object. Render link to the related object.
""" """
......
...@@ -378,7 +378,7 @@ class OOoChartWidget(Widget.Widget): ...@@ -378,7 +378,7 @@ class OOoChartWidget(Widget.Widget):
return extra_argument_dict return extra_argument_dict
def render_view(self, field, value, REQUEST=None, key=None, render_format='html'): def render_view(self, field, value, REQUEST=None, key=None, render_format='html', render_prefix=None):
""" """
Render a Chart in read-only. Render a Chart in read-only.
""" """
...@@ -386,7 +386,7 @@ class OOoChartWidget(Widget.Widget): ...@@ -386,7 +386,7 @@ class OOoChartWidget(Widget.Widget):
return self.render(field, key, value, REQUEST, render_format=render_format) return self.render(field, key, value, REQUEST, render_format=render_format)
def render_odf(self, field, key, value, REQUEST, render_format='ooo'): def render_odf(self, field, key, value, REQUEST, render_format='ooo', render_prefix=None):
""" """
Render a Chart for ODT Style. Render a Chart for ODT Style.
""" """
...@@ -399,7 +399,7 @@ class OOoChartWidget(Widget.Widget): ...@@ -399,7 +399,7 @@ class OOoChartWidget(Widget.Widget):
return content return content
def render(self, field, key, value, REQUEST, render_format='html'): def render(self, field, key, value, REQUEST, render_format='html', render_prefix=None):
""" """
Render a chart. Render a chart.
......
...@@ -220,7 +220,7 @@ class POSBoxWidget(Widget.Widget): ...@@ -220,7 +220,7 @@ class POSBoxWidget(Widget.Widget):
required=0, required=0,
group="order summary") group="order summary")
def render(self, field, key, value, REQUEST): def render(self, field, key, value, REQUEST, render_prefix=None):
""" """
Render point of sales widget. Render point of sales widget.
""" """
...@@ -242,7 +242,7 @@ class POSBoxWidget(Widget.Widget): ...@@ -242,7 +242,7 @@ class POSBoxWidget(Widget.Widget):
fastResourceEntry_display = field.get_value("display_fastResourceEntry"), fastResourceEntry_display = field.get_value("display_fastResourceEntry"),
) )
def render_javascript(self, field, key, value, REQUEST): def render_javascript(self, field, key, value, REQUEST, render_prefix=None):
here = REQUEST['here'] here = REQUEST['here']
page_template = getattr(here,field.get_value("javascript_ZPT")) page_template = getattr(here,field.get_value("javascript_ZPT"))
...@@ -259,7 +259,7 @@ class POSBoxWidget(Widget.Widget): ...@@ -259,7 +259,7 @@ class POSBoxWidget(Widget.Widget):
resource_category_fastResourceEntry = field.get_value('resource_category_fastResourceEntry') resource_category_fastResourceEntry = field.get_value('resource_category_fastResourceEntry')
) )
def render_view(self, field, value, REQUEST=None): def render_view(self, field, value, REQUEST=None, render_prefix=None):
""" """
Render point of sales widget Render point of sales widget
""" """
...@@ -286,6 +286,6 @@ class POSBox(ZMIField): ...@@ -286,6 +286,6 @@ class POSBox(ZMIField):
def render_css(self, value=None, REQUEST=None): def render_css(self, value=None, REQUEST=None):
return self.widget.render_css(self,'',value,REQUEST) return self.widget.render_css(self,'',value,REQUEST)
def render_javascript(self, value=None, REQUEST=None): def render_javascript(self, value=None, REQUEST=None, render_prefix=None):
return self.widget.render_javascript(self,'',value,REQUEST) return self.widget.render_javascript(self,'',value,REQUEST)
...@@ -97,7 +97,7 @@ class ParallelListWidget(Widget.MultiListWidget, ...@@ -97,7 +97,7 @@ class ParallelListWidget(Widget.MultiListWidget,
'MultiListField': Widget.MultiListWidgetInstance, 'MultiListField': Widget.MultiListWidgetInstance,
} }
def render(self, field, key, value, REQUEST): def render(self, field, key, value, REQUEST, render_prefix=None):
hash_list = generateSubForm(field, value, REQUEST) hash_list = generateSubForm(field, value, REQUEST)
# Call render on each sub field # Call render on each sub field
sub_field_render_list = [] sub_field_render_list = []
...@@ -111,7 +111,7 @@ class ParallelListWidget(Widget.MultiListWidget, ...@@ -111,7 +111,7 @@ class ParallelListWidget(Widget.MultiListWidget,
join(sub_field_render_list) join(sub_field_render_list)
return html_string return html_string
def render_htmlgrid(self, field, key, value, REQUEST): def render_htmlgrid(self, field, key, value, REQUEST, render_prefix=None):
hash_list = generateSubForm(field, value, REQUEST) hash_list = generateSubForm(field, value, REQUEST)
# Call render on each sub field # Call render on each sub field
sub_field_render_list = [] sub_field_render_list = []
...@@ -125,7 +125,7 @@ class ParallelListWidget(Widget.MultiListWidget, ...@@ -125,7 +125,7 @@ class ParallelListWidget(Widget.MultiListWidget,
return sub_field_render_list return sub_field_render_list
def render_sub_field(self, field, key, value, REQUEST, def render_sub_field(self, field, key, value, REQUEST,
sub_field_property_dict): sub_field_property_dict, render_prefix=None):
""" """
Render dynamically a subfield Render dynamically a subfield
""" """
......
...@@ -940,7 +940,7 @@ class PlanningBoxWidget(Widget.Widget): ...@@ -940,7 +940,7 @@ class PlanningBoxWidget(Widget.Widget):
return CSS_data return CSS_data
def render(self, field, key, value, REQUEST): def render(self, field, key, value, REQUEST, render_prefix=None):
""" """
Method called to render the HTML code relative to the planning. Method called to render the HTML code relative to the planning.
for that recover the structure previouly saved in the REQUEST, and then for that recover the structure previouly saved in the REQUEST, and then
...@@ -961,7 +961,7 @@ class PlanningBoxWidget(Widget.Widget): ...@@ -961,7 +961,7 @@ class PlanningBoxWidget(Widget.Widget):
# return HTML data # return HTML data
return HTML_data return HTML_data
def render_structure(self, field, REQUEST, context): def render_structure(self, field, REQUEST, context, render_prefix=None):
""" """
This method is the begining of the rendering procedure. it calls all This method is the begining of the rendering procedure. it calls all
methods needed to generate BasicStructure with ERP5 objects, and then methods needed to generate BasicStructure with ERP5 objects, and then
......
...@@ -102,7 +102,7 @@ class ZGDChartWidget(Widget.Widget): ...@@ -102,7 +102,7 @@ class ZGDChartWidget(Widget.Widget):
default='', default='',
required=0) required=0)
def render(self, field, key, value, REQUEST): def render(self, field, key, value, REQUEST, render_prefix=None):
""" """
This is where most things happens This is where most things happens
......
...@@ -94,7 +94,7 @@ class ZPyChartWidget(Widget.Widget): ...@@ -94,7 +94,7 @@ class ZPyChartWidget(Widget.Widget):
default='', default='',
required=0) required=0)
def render(self, field, key, value, REQUEST): def render(self, field, key, value, REQUEST, render_prefix=None):
""" """
Here, we just generate tags which will later call download Here, we just generate tags which will later call download
""" """
......
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