ViktorSodd
ViktorSodd

Reputation: 39

GAE ndb put() argument error

I am trying to save an object to GAE's datastore. When doing this I am getting the error:

Traceback (most recent call last):
  File "/Users/Soderstrom/google-cloud-sdk/.install/.backup/platform/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/runtime/wsgi.py", line 267, in Handle
    result = handler(dict(self._environ), self._StartResponse)
  File "/Users/Soderstrom/PycharmProjects/MyApp/lib/python2.7/site-packages/flask/app.py", line 1836, in __call__
    return self.wsgi_app(environ, start_response)
  File "/Users/Soderstrom/PycharmProjects/MyApp/lib/python2.7/site-packages/flask/app.py", line 1820, in wsgi_app
    response = self.make_response(self.handle_exception(e))
  File "/Users/Soderstrom/PycharmProjects/MyApp/lib/python2.7/site-packages/flask/app.py", line 1403, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/Users/Soderstrom/PycharmProjects/MyApp/lib/python2.7/site-packages/flask/app.py", line 1817, in wsgi_app
    response = self.full_dispatch_request()
  File "/Users/Soderstrom/PycharmProjects/MyApp/lib/python2.7/site-packages/flask/app.py", line 1477, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/Users/Soderstrom/PycharmProjects/MyApp/lib/python2.7/site-packages/flask/app.py", line 1381, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/Users/Soderstrom/PycharmProjects/MyApp/lib/python2.7/site-packages/flask/app.py", line 1475, in full_dispatch_request
    rv = self.dispatch_request()
  File "/Users/Soderstrom/PycharmProjects/MyApp/lib/python2.7/site-packages/flask/app.py", line 1461, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/Users/Soderstrom/PycharmProjects/MyApp/main.py", line 559, in backends
    db.save(v.getFastigheter(), '1')
TypeError: put() takes exactly 1 argument (2 given)

This is independent of the actual amount of arguments passed to the entity creator.

db.save(v.getSomeData(), '1')     <- main.py, line 559
db.load('1')

This is the db module:

class ndbc(ndb.Model):
    val = ndb.PickleProperty(compressed=True, indexed=False)
    key_name = ndb.PickleProperty(indexed=True)

    @classmethod
    def set(cls, key_t, val_t):
        entity = cls(val=val, key_name=key)

        entity.put()
        return val_t


    def save(obj, name):
    return ndbc.set(name, obj)

Upvotes: 0

Views: 112

Answers (1)

GAEfan
GAEfan

Reputation: 11370

Don't you mean entity = cls(val=val_t, key_name=key_t)? Also, key_name is an old db property. For ndb, you should use id:

https://docs.google.com/document/d/1AefylbadN456_Z7BZOpZEXDq8cR8LYu7QgI7bt5V0Iw/mobilebasic

Not sure id can be a PickleProperty. Interested to see if this works.

Upvotes: 1

Related Questions