[web2py] SQLCustomType bug with grids?
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.
[web2py] SQLCustomType str - list:int not working, 1.99.7
Hi I just updated my web2py from 1.99.4 to 1.99.7 and a select to my db stopped working. The field is a SQLCustomType that has native type string and type list:integer, this worked fine before but now it doesn't decode the value. BaseAdapter parse_value in dal.py if isinstance(value, unicode): value = value.encode('utf-8') elif isinstance(field_type, SQLCustomType): value = field_type.decoder(value) the value is unicode and so the decoder will not run. I need a conversion from string to list:integer because of the legacy database I'm working with, can this be fixed or is there another alternative to SQLCustomType?
[web2py] SQLCustomType and GAE noSQL
I just noticed the following about SQLCustomType in the book: This feature is marked as experimental. In practice is has been in web2py for long time and it works but it can make the code not portable, for example when the native type is database specific. It does not work on Google App Engine NoSQL. Is this a new change? I'm using 1.98.2 and am using SQLCustomType on GAE NoSQL (and am about to add another custom field). Will this break on upgrade? or by chance is the book wrong? thanks, christian
[web2py] SQLCustomType
Has this been deprecated? If not, a refresher on how to make a simplejson type and perhaps a section of the book devoted to custom types? -- Thadeus
Re: [web2py] SQLCustomType
On 02/01/2011 02:31 PM, Thadeus Burgess wrote: Has this been deprecated? If not, a refresher on how to make a simplejson type and perhaps a section of the book devoted to custom types? I'd like to see this, too. I need to create an upload Field that stores the files in Rackspace Cloud Files. I had initially thought that I could do it with custom_store and custom_delete but realized that I would need custom_retrieve, too. So it is probably best to subclass Field or use SQLCustomType or something. -- Art Z -- Art Zemon, President Hen's Teeth Network http://www.hens-teeth.net/ The source of reliable, secure e-commerce web hosting http://www.hens-teeth.net/html/hosting/ecommerce_hosting.php Phone: (866)HENS-NET or (636)447-3030 ext. 200
[web2py] SQLCustomType no longer importable
Traceback (most recent call last): File C:\Bin\web2py\gluon\restricted.py, line 188, in restricted exec ccode in environment File C:/Bin/web2py/applications/eden/models/00_db.py, line 21, in module from gluon.sql import SQLCustomType ImportError: cannot import name SQLCustomType Are we not supposed to use these any more? If not, what should they be replaced by? F