Hi everybody, I've tried to use SQLCustomType with grids but always get this error (2.8.2 version):
<type 'exceptions.AttributeError'> 'SQLCustomType' object has no attribute 'endswith' It works fine with SQLTABLE (as exposed below) but not with 'grid' neither 'smartgrid'. It also fails with MySQL backend. is there a way to make this work or may i open a bug ticket?. Code in a controller (the aim is to store datetime in database as unixtime -seconds since epoch-): def custom(): # the aim is to store datetime in database as unixtime -seconds since epoch- from gluon.dal import SQLCustomType from datetime import datetime from calendar import timegm ut_dt = SQLCustomType( type = 'datetime', native = 'integer', encoder = (lambda dt: timegm(dt.utctimetuple())), decoder = (lambda ut: datetime.utcfromtimestamp(ut)) ) db = DAL('sqlite:memory:') db.define_table('event', Field('name', 'string'), Field('day_and_time', type=ut_dt) #~ Field('day_and_time', 'datetime') ) db.event.insert(name='Birthday', day_and_time=datetime(2000, 1, 1, 0, 0, 0)) db.event.insert(name='Speaks!', day_and_time=datetime(2002, 2, 2, 10, 10, 10)) # 'SQLTABLE' works but 'grid' and 'smartgrid' don't, unless you change ' day_and_time' type to datetime html = SQLTABLE(db(db.event).select()) #~ html = SQLFORM.grid(db.event) #~ html = SQLFORM.smartgrid(db.event) return dict(html=html) My actual workaround is to use 'filter_in' and 'filter_out'. By the way, there's an error in the manual at Custom Field types section. It says: native is the name of the field as far as the database is concerned where it should say: native is the type of the field as far as the database is concerned Regards! -- 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/groups/opt_out.