Matt Patey
unread,Jun 15, 2009, 12:26:09 PM6/15/09Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to ToscaWidgets-discuss
I'm using FormFieldRepeaterS to display FieldSetS 0 or more times.
This works fine if I populate my form with a list containing at least
one element, however, if I pass it a list with zero elements I get the
following error:
File '/home/mlp/.virtualenvs/order_cancellation_ng/lib/python2.5/site-
packages/ToscaWidgets-0.9.5dev_20090407-py2.5.egg/tw/core/base.py',
line 1046 in update_params
max(d['repetitions'], len(d['value']) + d.extra))
TypeError: object of type 'NoneType' has no len()
One 'workaround' was to set the repetitions parameter sent to the
FormFieldRepeater to '1', however this was not ideal as it resulted in
an unpopulated FieldSet if the list contained zero elements.
Another workaround is to override the FormFieldRepeater class'
update_params() implementation:
class ZeroRepetitionFieldRepeater(FormFieldRepeater):
"""
Hack to ensure FormFieldRepeater won't crash when repetitions are
set to
0.
"""
def update_params(self, param_dict):
if param_dict['value'] == None:
param_dict['value'] = []
super(ZeroRepetitionFieldRepeater, self).update_params
(param_dict)
I suspect that the inability to set repetitions to zero is a bug, but
maybe I'm missing something here. Has anyone else had problems setting
repetitions to 0? Is this perhaps related to the specific version of
ToscaWidgets I'm using (0.9.3dev_20090407) ?