Am Montag, 18. Januar 2016 18:06:32 UTC+1 schrieb Anthony:
>
> Maybe this will work: 
> http://www.web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#Custom-Field-types--experimental-
>

This looks good. Don't know why I didn't see this before...

This seems to work:

from gluon.dal import SQLCustomType

realbool = SQLCustomType(
     type ='boolean',
     native='boolean',
     encoder = (lambda x: "true" if x else "false"),
     decoder = (lambda x: True if str(x)=="True" else False)
)

db.define_table('test_2', Field('b',type=realbool))

db.test_2.insert(b=True)
db.test_2.insert(b=False)


Thank you.

-- 
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.

Reply via email to