私は以下のようにコードを書きます
from google.appengine.ext import ndb
__metaclass__ = type
class UserSession(ndb.Model):
session = ndb.BlobProperty()
class KV:
@staticmethod
def get(id):
r = ndb.Key(UserSession, int(id)).get()
if r:
return r.session
@staticmethod
def set(id, value):
return UserSession.get_or_insert(int(id), session=value)
@staticmethod
def delete(id):
ndb.Key(UserSession, int(id)).delete()
私が書く場所
id = 1
key = ndb.Key(UserSession, int(id))
UserSession.get_or_insert(key, session=1)
SDKレイズ
TypeError: name must be a string; received Key('UserSession', 1)
KV.get() を呼び出すと
SDKレイズ
ファイル "/home/bitcoin/42btc/zapp/_plugin/auth/model/gae/user.py"、14 行目、get
r = ndb.Key(UserSession,int(id)).get()
...
BadRequestError: キー ID/名前がありません
では、NDB の使用方法は?