I have a Contest entity which uses a ListProperty to store keys of Candidate entities. Here are some details:
class Contest(db.Model):
candidates = db.ListProperty(db.Key)
def create_candidate_objects(self):
put_list = []
for n, name in enumerate(self.tmp_candidates):
put_list.append(Candidate(parent = self, name = name))
keys = db.put(put_list)
self.candidates = keys
self.put()
class Candidate(db.Model):
name = db.StringProperty(required = True)
When I do this query:
c = models.Candidate.all().ancestor(contest).fetch(2)
Everything works fine.
But when I do a query using the ListProperty like this:
c = db.get(contest.candidates)
I get the error
KindError: No implementation for kind 'Candidate'
Can you help me understand why the last query does not work? I have imported the Candidate class into the module that is doing the query.
UPDATE: Note that his is on the dev server in case that might make a difference.
UPDATE2:
As suggested by Nick, this works:
c2 = models.Candidate.get(contest.candidates)
but this does not work (raises KindError):
from models import Candidate
c = db.get(contest.candidates)
UPDATE3:
The offending line occurs in test code so I can't try this particular failure on the production server. I have used the exact same line elsewhere and it does work on both the dev and production servers.
Nick asked about imports, and I am doing this in my test code:
sys.path.append("/usr/local/google_appengine/lib/simplejson")
import simplejson as json
but everything else is just typical.
Try this:
Most likely you're defining
Candidate
in another module you haven't imported. Where isCandidate
defined? Have you imported the module it's in when you calldb.get
? CallingCandidate.get(key_list)
should work, since it forces you to have a validCandidate
when you call it.