Commit d2821a6c authored by Nicolas Delaby's avatar Nicolas Delaby

* Unify renderer signatures between render_odt and render_odg

* Use only positional parameters
* update docsrings
reviewed by Romain


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@31782 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 8e853f53
...@@ -180,6 +180,8 @@ class Widget: ...@@ -180,6 +180,8 @@ class Widget:
Return a field value rendered in odt format. Return a field value rendered in odt format.
- as_string return value as string or as xml object - as_string return value as string or as xml object
- attr_dict can be used for additional attributes (like style). - attr_dict can be used for additional attributes (like style).
- ooo_builder wrapper of ODF zipped archive usefull to insert images
- local_name local-name of the node returned by this render
""" """
if attr_dict is None: if attr_dict is None:
attr_dict = {} attr_dict = {}
...@@ -191,14 +193,14 @@ class Widget: ...@@ -191,14 +193,14 @@ class Widget:
return text_node return text_node
def render_odg(self, field, value, as_string, ooo_builder, REQUEST, def render_odg(self, field, value, as_string, ooo_builder, REQUEST,
render_prefix, attr_dict): render_prefix, attr_dict, local_name):
""" """
Default render odg for widget - to be overwritten in field classes. Default render odg for widget - to be overwritten in field classes.
Return a field node rendered in odg format. Return a field node rendered in odg format.
if as_string is True (default) the returned value is a string (xml - as_string return value as string or as xml object
reprensation of the node), if it's False, the value returned is the node - attr_dict can be used for additional attributes (like style).
object. - ooo_builder wrapper of ODF zipped archive usefull to insert images
attr_dict can be used for additional parameters (like style). - local_name local-name of the node returned by this render
""" """
if attr_dict is None: if attr_dict is None:
attr_dict = {} attr_dict = {}
...@@ -852,15 +854,14 @@ class MultiItemsWidget(ItemsWidget): ...@@ -852,15 +854,14 @@ class MultiItemsWidget(ItemsWidget):
result.append(d[e].replace('\xc2\xa0', '')) result.append(d[e].replace('\xc2\xa0', ''))
return result return result
def render_odg(self, field, value, as_string, ooo_builder, REQUEST=None, def render_odg(self, field, value, as_string, ooo_builder, REQUEST,
render_prefix=None, attr_dict=None): render_prefix, attr_dict, local_name):
if value is None: if value is None:
return None return None
value_list = self.render_items_odf(field, value, REQUEST) value_list = self.render_items_odf(field, value, REQUEST)
value = ', '.join(value_list).decode('utf-8') value = ', '.join(value_list).decode('utf-8')
return Widget.render_odg(self, field=field, value=value, as_string=as_string, return Widget.render_odg(self, field, value, as_string, ooo_builder,
ooo_builder=ooo_builder, REQUEST=REQUEST, render_prefix=render_prefix, REQUEST, render_prefix, attr_dict, local_name)
attr_dict=attr_dict)
class ListWidget(SingleItemsWidget): class ListWidget(SingleItemsWidget):
"""List widget. """List widget.
...@@ -1329,15 +1330,14 @@ class DateTimeWidget(Widget): ...@@ -1329,15 +1330,14 @@ class DateTimeWidget(Widget):
return text_node return text_node
def render_odg(self, field, value, as_string, ooo_builder, REQUEST, def render_odg(self, field, value, as_string, ooo_builder, REQUEST,
render_prefix, attr_dict): render_prefix, attr_dict, local_name):
""" """
Return a field value rendered in odt format. Return a field value rendered in odt format.
- as_string return value as string or as xml object - as_string return value as string or as xml object
- attr_dict can be used for additional attributes (like style). - attr_dict can be used for additional attributes (like style).
""" """
return self.render_odt(field=field, value=value, as_string=as_string, return self.render_odt(field, value, as_string, ooo_builder, REQUEST,
ooo_builder=ooo_builder, REQUEST=REQUEST, render_prexix=render_prefix, render_prefix, attr_dict, local_name)
attr_dict=attr_dict, local_name='p')
DateTimeWidgetInstance = DateTimeWidget() DateTimeWidgetInstance = DateTimeWidget()
...@@ -1654,13 +1654,12 @@ class FloatWidget(TextWidget): ...@@ -1654,13 +1654,12 @@ class FloatWidget(TextWidget):
return text_node return text_node
def render_odg(self, field, value, as_string, ooo_builder, REQUEST, def render_odg(self, field, value, as_string, ooo_builder, REQUEST,
render_prefix, attr_dict): render_prefix, attr_dict, local_name):
if attr_dict is None: if attr_dict is None:
attr_dict = {} attr_dict = {}
value = field.render_pdf(value) value = field.render_pdf(value)
return Widget.render_odg(self, field=field, value=value, as_string=as_string, return Widget.render_odg(self, field, value, as_string, ooo_builder,
ooo_builder=ooo_builder, REQUEST=REQUEST, render_prefix=render_prefix, REQUEST, render_prefix, attr_dict, local_name)
attr_dict=attr_dict)
FloatWidgetInstance = FloatWidget() FloatWidgetInstance = FloatWidget()
......
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