Commit 65315be6 authored by Douglas's avatar Douglas Committed by Ivan Tyagov

erp5_wendelin: fix crash in data array preview if shape is (0, 0)

Related bug report: https://nexedi.erp5.net/bug_module/20160711-1D0657A.

/reviewed-on nexedi/wendelin!21
parent e8154cf0
...@@ -3,6 +3,10 @@ from Products.ERP5Type.Document import newTempBase ...@@ -3,6 +3,10 @@ from Products.ERP5Type.Document import newTempBase
if context.getArray() is None: if context.getArray() is None:
return [] return []
length = context.getArrayShape()[0]
if length == 0:
return []
class SequenceSliceMap(): class SequenceSliceMap():
def __init__(self, sequence_slice, usual_slice_length, total_length): def __init__(self, sequence_slice, usual_slice_length, total_length):
self.sequence_slice = sequence_slice self.sequence_slice = sequence_slice
...@@ -37,7 +41,7 @@ def createTempBase(nr, row): ...@@ -37,7 +41,7 @@ def createTempBase(nr, row):
**{col[0]: str(getElement(row, i)) for i, col in column_iterator}) **{col[0]: str(getElement(row, i)) for i, col in column_iterator})
length = context.getArrayShape()[0]
# never access more than 1000 lines at once # never access more than 1000 lines at once
list_lines = min(list_lines, limit, 1000) list_lines = min(list_lines, limit, 1000)
......
...@@ -61,7 +61,9 @@ ...@@ -61,7 +61,9 @@
<item> <item>
<key> <string>center</string> </key> <key> <string>center</string> </key>
<value> <value>
<list/> <list>
<string>my_size_warning</string>
</list>
</value> </value>
</item> </item>
<item> <item>
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
<list> <list>
<string>columns</string> <string>columns</string>
<string>editable</string> <string>editable</string>
<string>hidden</string>
<string>list_method</string> <string>list_method</string>
<string>title</string> <string>title</string>
<string>url_columns</string> <string>url_columns</string>
...@@ -62,6 +63,10 @@ ...@@ -62,6 +63,10 @@
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent> <persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value> </value>
</item> </item>
<item>
<key> <string>editable</string> </key>
<value> <string></string> </value>
</item>
<item> <item>
<key> <string>field_id</string> </key> <key> <string>field_id</string> </key>
<value> <string></string> </value> <value> <string></string> </value>
...@@ -70,6 +75,12 @@ ...@@ -70,6 +75,12 @@
<key> <string>form_id</string> </key> <key> <string>form_id</string> </key>
<value> <string></string> </value> <value> <string></string> </value>
</item> </item>
<item>
<key> <string>hidden</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item> <item>
<key> <string>list_method</string> </key> <key> <string>list_method</string> </key>
<value> <string></string> </value> <value> <string></string> </value>
...@@ -85,7 +96,7 @@ ...@@ -85,7 +96,7 @@
<item> <item>
<key> <string>url_columns</string> </key> <key> <string>url_columns</string> </key>
<value> <value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent> <persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value> </value>
</item> </item>
</dictionary> </dictionary>
...@@ -118,10 +129,14 @@ ...@@ -118,10 +129,14 @@
<key> <string>form_id</string> </key> <key> <string>form_id</string> </key>
<value> <string>Base_viewFieldLibrary</string> </value> <value> <string>Base_viewFieldLibrary</string> </value>
</item> </item>
<item>
<key> <string>hidden</string> </key>
<value> <int>0</int> </value>
</item>
<item> <item>
<key> <string>list_method</string> </key> <key> <string>list_method</string> </key>
<value> <value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent> <persistent> <string encoding="base64">AAAAAAAAAAU=</string> </persistent>
</value> </value>
</item> </item>
<item> <item>
...@@ -165,12 +180,25 @@ ...@@ -165,12 +180,25 @@
<dictionary> <dictionary>
<item> <item>
<key> <string>_text</string> </key> <key> <string>_text</string> </key>
<value> <string>python: [(col[0], None) for col in here.DataArray_getArrayColumnList()]</string> </value> <value> <string>python: context.getArrayShape()[0] == 0</string> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
</record> </record>
<record id="4" aka="AAAAAAAAAAQ="> <record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="TALESMethod" module="Products.Formulator.TALESField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>python: [(col[0], None) for col in here.DataArray_getArrayColumnList()]</string> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="5" aka="AAAAAAAAAAU=">
<pickle> <pickle>
<global name="Method" module="Products.Formulator.MethodField"/> <global name="Method" module="Products.Formulator.MethodField"/>
</pickle> </pickle>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="LabelField" module="Products.Formulator.StandardFields"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>my_size_warning</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
<value>
<dictionary/>
</value>
</item>
<item>
<key> <string>overrides</string> </key>
<value>
<dictionary>
<item>
<key> <string>css_class</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>default</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>editable</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>enabled</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>extra</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>hidden</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>tales</string> </key>
<value>
<dictionary>
<item>
<key> <string>css_class</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>default</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>editable</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>enabled</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>extra</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>hidden</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>css_class</string> </key>
<value> <string>hidden_label</string> </value>
</item>
<item>
<key> <string>default</string> </key>
<value> <string>Cannot render array when the first dimension\'s size is 0.</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>editable</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>enabled</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>extra</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>hidden</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Size Warning</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="Method" module="Products.Formulator.MethodField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>method_name</string> </key>
<value> <string>python: context.getArrayShape()[0] == 0</string> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="TALESMethod" module="Products.Formulator.TALESField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>python: context.getArrayShape() is not None and context.getArrayShape()[0] != 0</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
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