On Thursday, July 6, 2017 at 3:29:11 AM UTC-7, Dave S wrote: [...]
> For the other, my controller does the usual "form = SQFORM(db.tab2)", where > tab2 has a field "partof" ref tab1, and a string field I want to get > autofocus, so I set the widget, and I set the default value for a boolean > field according to a request.vars value. I get a format error: > > 4. > 35. > 36. > 37. > 38. > 39. > 40. > > Traceback (most recent call last): > File > "C:\Users\Dave\web2py_win\web2py_win-2.15.0b1\web2py\gluon\restricted.py", > line 219, in restricted > exec(ccode, environment) > File > "C:/Users/Dave/web2py_win/web2py_win-2.15.0b1/web2py/applications/shortcuts/controllers/default.py" > <http://127.0.0.1:8000/admin/default/edit/shortcuts/controllers/default.py>, > line 178, in <module> > File > "C:\Users\Dave\web2py_win\web2py_win-2.15.0b1\web2py\gluon\globals.py", line > 406, in <lambda> > self._caller = lambda f: f() > File > "C:/Users/Dave/web2py_win/web2py_win-2.15.0b1/web2py/applications/shortcuts/controllers/default.py" > <http://127.0.0.1:8000/admin/default/edit/shortcuts/controllers/default.py>, > line 56, in addsegment > form = SQLFORM(db.segment) > File > "C:\Users\Dave\web2py_win\web2py_win-2.15.0b1\web2py\gluon\sqlhtml.py", line > 1406, in __init__ > inp = self.widgets.options.widget(field, default) > File > "C:\Users\Dave\web2py_win\web2py_win-2.15.0b1\web2py\gluon\sqlhtml.py", line > 324, in widget > options = requires[0].options() > File > "C:\Users\Dave\web2py_win\web2py_win-2.15.0b1\web2py\gluon\validators.py", > line 600, in options > self.build_set() > File > "C:\Users\Dave\web2py_win\web2py_win-2.15.0b1\web2py\gluon\validators.py", > line 586, in build_set > records = self.dbset(table).select(*fields, **dd) > File > "C:\Users\Dave\web2py_win\web2py_win-2.15.0b1\web2py\gluon\packages\dal\pydal\objects.py", > line 2211, in select > return adapter.select(self.query, fields, attributes) > File > "C:\Users\Dave\web2py_win\web2py_win-2.15.0b1\web2py\gluon\packages\dal\pydal\adapters\sqlite.py", > line 82, in select > return super(SQLite, self).select(query, fields, attributes) > File > "C:\Users\Dave\web2py_win\web2py_win-2.15.0b1\web2py\gluon\packages\dal\pydal\adapters\base.py", > line 760, in select > return self._select_aux(sql, fields, attributes, colnames) > File > "C:\Users\Dave\web2py_win\web2py_win-2.15.0b1\web2py\gluon\packages\dal\pydal\adapters\base.py", > line 739, in _select_aux > return processor(rows, fields, colnames, cacheable=cacheable) > File > "C:\Users\Dave\web2py_win\web2py_win-2.15.0b1\web2py\gluon\packages\dal\pydal\adapters\base.py", > line 305, in parse > for row in rows > File > "C:\Users\Dave\web2py_win\web2py_win-2.15.0b1\web2py\gluon\packages\dal\pydal\adapters\base.py", > line 231, in _parse > value = self.parse_value(value, fit, ft, blob_decode) > File > "C:\Users\Dave\web2py_win\web2py_win-2.15.0b1\web2py\gluon\packages\dal\pydal\adapters\base.py", > line 198, in parse_value > return self.parser.parse(value, field_itype, field_type) > File > "C:\Users\Dave\web2py_win\web2py_win-2.15.0b1\web2py\gluon\packages\dal\pydal\parsers\__init__.py", > line 101, in parse > return self.registered[field_itype](value, field_type) > File > "C:\Users\Dave\web2py_win\web2py_win-2.15.0b1\web2py\gluon\packages\dal\pydal\parsers\__init__.py", > line 76, in __call__ > return self.call(value, field_type) > File > "C:\Users\Dave\web2py_win\web2py_win-2.15.0b1\web2py\gluon\packages\dal\pydal\parsers\__init__.py", > line 70, in _call_with_extras > return self.f(self.parser, value, **extras) > File > "C:\Users\Dave\web2py_win\web2py_win-2.15.0b1\web2py\gluon\packages\dal\pydal\parsers\sqlite.py", > line 19, in _decimal > value = ('%.' + decimals + 'f') % value > ValueError: unsupported format character ' ' (0x20) at index 2 > > This is whistled down at *File C:\Users\Dave\web2py_win\web2py_win-2.15.0b1\web2py\gluon\packages\dal\pydal\parsers\sqlite.py in _decimal at line 19* code arguments variables Function argument list (self=<pydal.parsers.sqlite.SQLiteParser object>, value=3.1, decimals=' 1') Code listing 14. 15. 16. 17. 18. 19. 20. 21. 22. 23. def decimal_extras(self, field_type): return {'decimals': field_type[8:-1].split(',')[-1]} @for_type('decimal') def _decimal(self, value, decimals): value = ('%.' + decimals + 'f') % value return Decimal(value) @for_type('date') def _date(self, value): Variables decimals ' 1' value 3.1 I'm not sure where the "3.1" comes from, but the error might have been Field("duration", "decimal(5, 1)", default=None, writable=False), instead of Field("duration", "decimal(5,1)", default=None, writable=False), /dps -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.