Can you help debug? In gluon/validators.py

    def __call__(self, value):
        try:
            v = decimal.Decimal(str(value)) # << line 725
            ...
        except (ValueError, TypeError, decimal.InvalidOperation):
            pass
        return (value, self.error_message)

why is the exception not caught?

On Sep 13, 2:22 am, Kenneth <[email protected]> wrote:
> Hello,
>
> I have a tablefield defined as decimal(10,2).
>
> Fields for SQLFORM is defined as:
> fields=['price_consumer']
> field_labels=['price_cunsumer': T('price consumer')]
>
> and then the form is generated as:
> form = SQLFORM(db.product, fields=fields, labels=field_labels)
>
> When I try to fill the form with values I get a Internal error because
> i tried to put the price with a comma, so 12,50 is not allowed but
> 12.50 is.
>
> How to indicate the problem and not to get the Internal error?
>
> Error traceback:
> Traceback (most recent call last):
>   File "gluon/restricted.py", line 186, in restricted
>     exec ccode in environment
>   File "/data/domains/exp-kal.nudata.fi/applications/init/controllers/
> product.py", line 99, in <module>
>   File "gluon/globals.py", line 96, in <lambda>
>     self._caller = lambda f: f()
>   File "gluon/tools.py", line 2219, in f
>     return action(*a, **b)
>   File "/data/domains/exp-kal.nudata.fi/applications/init/controllers/
> product.py", line 81, in edit
>     if form.accepts(request.vars, session):
>   File "gluon/sqlhtml.py", line 906, in accepts
>     hideerror=hideerror,
>   File "gluon/html.py", line 1512, in accepts
>     status = self._traverse(status,hideerror)
>   File "gluon/html.py", line 522, in _traverse
>     newstatus = c._traverse(status,hideerror) and newstatus
>   File "gluon/html.py", line 522, in _traverse
>     newstatus = c._traverse(status,hideerror) and newstatus
>   File "gluon/html.py", line 522, in _traverse
>     newstatus = c._traverse(status,hideerror) and newstatus
>   File "gluon/html.py", line 522, in _traverse
>     newstatus = c._traverse(status,hideerror) and newstatus
>   File "gluon/html.py", line 529, in _traverse
>     newstatus = self._validate()
>   File "gluon/html.py", line 1300, in _validate
>     (value, errors) = validator(value)
>   File "gluon/validators.py", line 2313, in __call__
>     return self.other(value)
>   File "gluon/validators.py", line 725, in __call__
>     v = decimal.Decimal(str(value))
>   File "/usr/lib64/python2.5/decimal.py", line 614, in __new__
>     self._sign, self._int, self._exp =
> context._raise_error(ConversionSyntax)
>   File "/usr/lib64/python2.5/decimal.py", line 2325, in _raise_error
>     raise error, explanation
> InvalidOperation

Reply via email to