google-app-enginegoogle-cloud-datastoreapp-engine-ndb

Google App Engine Data store issue: Getting TypeError: Cannot set non-property when trying to insert into DataSTore


Model definition

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

Code to add to Datastore. This results in the TypeError: Cannot set non-property Sourcein (full error at end of the post)

Any help in understanding what is happening will be greatly appreciated.

data ={}
data['SeqNumberStart']=0
data['SeqNumberEnd']=0
data['key']=seqKey
data['Sourcein']='user_IOT'
data['Destin']='user_SmartHome'
SeqNumbers(**data).put()

Full Error in GAE logs

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

Solution

  • You need to initialize the properties for Sourcein and Destin. Just put the parenthesis at the end:

    Sourcein = ndb.StringProperty()
    Destin = ndb.StringProperty()