http://stackoverflow.com/questions/7767808/unable-to-write-to-appengine-datastore-using-web2pys-dal/7768108#7768108
I've just started using web2py with Google AppEngine for an app of mine. For
some reason, I'm unable to save/retrieve data using the DAL. Here's the code
I'm using:
At the end of db.py:
from aeoid import middleware
from aeoid import users
import json
db.define_table('files',
db.Field('name', 'text'),
db.Field('path', 'text'),
db.Field('version', 'text', default="live"),
db.Field('hash', 'text'),
db.Field('data', 'text'),
db.Field('meta', 'text',
default=json.dumps({'date':str(request.now)})),
db.Field('contributors', 'text',
default=json.dumps([users.get_current_user()])),
db.Field('lasttime', 'datetime', default=request.now)
)
In my controller:
name = "TEST"
db.files[0] = dict(hash=name, name=name, path=name)
textobj = db.files[1]
if textobj is None:
print "Fail: 500 Internal Server Error"
Here, textobj is always None for some reason.
What am I doing wrong?