*controllers/api.py*
import table_test
def test():
return table_test.test
*modules/table_test.py*
from gluon.dal import *
from gluon.validators import *
from gluon import current
import field_constructor
db = DAL('sqlite://test.sqlite', pool_size = 1)
def on_define_test(table):
T = current.T
table.test.label = T('Test')
table.test.requires = IS_NOT_EMPTY()
table.test.widget = field_constructor.widget_string
test = db.define_table('test',
Field('test'),
on_define = on_define_test)
*modules/field_constructor.py*
from gluon import *
widget_string = lambda field, value: \
SQLFORM.widgets.string.widget(field, value,
_class = "form-control string",
_placeholder = current.T('Should be
filled') )
ERROR:Rocket.Errors.Thread-6:Traceback (most recent call last):
File "/Users/sugizo/learn/python/web2py/gluon/rocket.py", line 1288, in
run
self.run_app(conn)
File "/Users/sugizo/learn/python/web2py/gluon/rocket.py", line 1802, in
run_app
self.write(data, sections)
File "/Users/sugizo/learn/python/web2py/gluon/rocket.py", line 1722, in
write
self.conn.sendall(b'%x\r\n%s\r\n' % (len(data), to_bytes(data,
'ISO-8859-1')))
TypeError: object of type 'Field' has no len()
error only appears in terminal :
python ~/learn/python/web2py/web2py.py --nogui --no-banner -a a -i 0.0.0.0 -p
8000
any hints ?
thx n best regards,
stifan
--
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/web2py/407d6587-031e-4872-a32e-c6743ef4c796%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.