A patch for ../sqlkit/widgets/table/columns.py

6 views
Skip to first unread message

Chris Green

unread,
Mar 15, 2016, 11:51:42 AM3/15/16
to sql...@googlegroups.com
I don't know how to progress this really. I know there's a recent
thread about moving the code to github so maybe this should wait.

Anyway, there's a problem when sqledit/sqlkit encounters empty or None
values in a numeric column. It throws exceptions like:-

Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/sqlkit/widgets/table/columns.py", line 170, in cell_data_func_cb formatted_value = self.field.format_value(value)
File "/usr/lib/python2.7/dist-packages/sqlkit/fields.py", line 964, in format_value return numbers.format_decimal(value, format=format or self.format, locale=self.locale)
File "/usr/lib/python2.7/dist-packages/babel/numbers.py", line 166, in format_decimal return pattern.apply(number, locale)
File "/usr/lib/python2.7/dist-packages/babel/numbers.py", line 563, in apply a, b = split_number(bankersround(abs(value), self.frac_prec[1]))
TypeError: bad operand type for abs(): 'unicode'


The patch just detects empty or None values and skips the formatting:-

170c170,173
< formatted_value = self.field.format_value(value)
---
> if value != '' and value != None:
> formatted_value = self.field.format_value(value)
> else:
> formatted_value = ''

This is in /usr/lib/python2.7/dist-packages/sqlkit/widgets/table/columns.py.


--
Chris Green
Reply all
Reply to author
Forward
0 new messages