在遇到错误
BadValueError: Virtual property is read-only
我在文档中没有找到有关此错误的任何内容。这是什么意思?这是代码的相关部分。它一直有效,直到最近的 SDK 更新。
date = dt.datetime.strptime(self.json['birthday'],"%Y-%m-%d").date()
if self.json.has_key('avatar'):
img = base64.b64decode(self.json['avatar'])
else:
img = None
log.info('No avatar')
user = db.User(
name=self.json['name'],
password=self.json['password'],
full_name=self.json['full_name'],
email = self.json['email'],
birthday = date,
avatar = img)
user.put()
服务器日志
File "/api/tornado/web.py", line 1064, in _execute
getattr(self, self.request.method.lower())(*args, **kwargs)
File "user.py", line 31, in post
avatar = img)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/ext/db/__init__.py", line 970, in __init__
prop.__set__(self, value)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/ext/db/__init__.py", line 615, in __set__
setattr(model_instance, self._attr_name(), value)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/ext/db/__init__.py", line 3874, in __set__
raise BadValueError('Virtual property is read-only')
BadValueError: Virtual property is read-only
INFO 2013-06-08 07:44:37,776 server.py:585] default: "POST /api/user/create HTTP/1.1" 500 93
数据库模型
class User(db.Model):
name = db.StringProperty(required=True)
password = db.StringProperty(required=True)
email = db.StringProperty(required=True)
full_name = db.StringProperty()
birthday = db.DateProperty()
avatar = db.BlobProperty()
如果我删除
avatar = img
然后是上面一行的错误。