This is a problem
Datetime objects in the pyDLA are not json serializable. In a pevious version of web2py's DAL json serializion did work fine.
I use Version 15.3 of pyDAL with python2.7 on Ubuntu 14.04.2 LTS.
Here ist a small program which demonstrates the issue:
from pydal import DAL, Field from datetime import datetime db = DAL('sqlite://storage.db', folder="test_databases") db.define_table('test_table', Field('date_field', 'datetime')) db.test_table.insert(date_field=datetime.now()) rows = db().select(db.test_table.ALL) print(rows.as_json())
Which gives this output on my machine:
Traceback (most recent call last):
File "db_text.py", line 13, in <module>
print(rows.as_json())
File "/usr/local/lib/python2.7/dist-packages/pydal/objects.py", line 2741, in as_json
return json.dumps(items)
File "/usr/lib/python2.7/json/__init__.py", line 243, in dumps
return _default_encoder.encode(obj)
File "/usr/lib/python2.7/json/encoder.py", line 207, in encode
chunks = self.iterencode(o, _one_shot=True)
File "/usr/lib/python2.7/json/encoder.py", line 270, in iterencode
return _iterencode(o, 0)
File "/usr/lib/python2.7/json/encoder.py", line 184, in default
raise TypeError(repr(o) + " is not JSON serializable")
TypeError: datetime.datetime(2015, 3, 27, 13, 37, 7) is not JSON serializable
—
Reply to this email directly or view it on GitHub.
--
-- mail from:GoogleGroups "web2py-developers" mailing list
make speech: web2py-d...@googlegroups.com
unsubscribe: web2py-develop...@googlegroups.com
details : http://groups.google.com/group/web2py-developers
the project: http://code.google.com/p/web2py/
official : http://www.web2py.com/
---
You received this message because you are subscribed to the Google Groups "web2py-developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to web2py-develop...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Yes.