google app engine - Update entities transactionally within a method -


for application have users voting on issues, separate datastores votes , issues. want , down vote totals updated whnever user votes (or changes original vote), i'm trying updating issue transactionally within vote.method. this, have transaction:

@ndb.transactional def gettochange(vote):     key = ndb.key('issue', vote.iid)     issue = key.get()     return issue 

then, within @vote.method call transactional function:

@vote.method(request_fields=('uid', 'iid', 'vote'), name='vote.add', path ='addvote') def addvote(self, vote):    vote.put()    = gettochange(vote)    if newvote.vote == true:       i.uptotal += 1    if newvote.vote == false:       i.downtotal += 1    i.put()    return vote 

however, gives me 503 error, , in logs spot "nonetype has no attribute uptotal", suggests entity isn't being retrieved. doing wrong?

edit: more details @vote.method takes user id (uid), issue id (the id of issue in issue datastore), , boolean 'vote' in request. vote stored vote.put(). call transactional method retrieve issue using iid request. i've added more code show i'm trying issue.

right, sorted! problem iid property using in vote model, why never able retrieve correct issue.

in vote model, changed iid ndb.keyproperty(kind=issue). trying use integer id datastore didn't work though; commented above, gave protocolbufferdecodeerror "corrupted". however, passing 64bit entitykey in request works! so, api uses entitykey helper property issues.


Comments