模型定义
class SeqNumbers(ndb.Model):
"""APNS Server -- SeqNumbers object that stores sequence number of stored messages between two devices"""
SeqNumberStart = ndb.IntegerProperty(required=True)
SeqNumberEnd = ndb.IntegerProperty(required=True)
Sourcein = ndb.StringProperty
Destin = ndb.StringProperty
要添加到数据存储区的代码。这导致了 TypeError:无法设置非属性Sourcein(帖子末尾的完整错误)
非常感谢任何有助于理解正在发生的事情的帮助。
data ={}
data['SeqNumberStart']=0
data['SeqNumberEnd']=0
data['key']=seqKey
data['Sourcein']='user_IOT'
data['Destin']='user_SmartHome'
SeqNumbers(**data).put()
GAE日志中的完全错误
E 02:08:17.725 Encountered unexpected error from ProtoRPC method implementation: TypeError (Cannot set non-property Sourcein)
Traceback (most recent call last):
File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/protorpc-1.0/protorpc/wsgi/service.py", line 181, in protorpc_service_app
response = method(instance, request)
File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/endpoints-1.0/endpoints/api_config.py", line 1332, in invoke_remote
return remote_method(service_instance, request)
File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/protorpc-1.0/protorpc/remote.py", line 414, in invoke_remote_method
response = method(service_instance, request)
File "/base/data/home/apps/s~chatimegae/v1.388953439373110592/apns_server.py", line 588, in sendMsg
SeqNumbers(**data).put()
File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/ext/ndb/model.py", line 2942, in __init__
self._set_attributes(kwds)
File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/ext/ndb/model.py", line 2987, in _set_attributes
raise TypeError('Cannot set non-property %s' % name)
TypeError: Cannot set non-property Sourcein
答案 0 :(得分:6)
您需要初始化Sourcein和Destin的属性。把括号放在最后:
Sourcein = ndb.StringProperty()
Destin = ndb.StringProperty()