问题
I'm trying to access a reference property of an ndb PolyModel subclass from a db Expando subclass. My two classes look like this:
class Foo(polymodel.PolyModel):
...
class Bar(db.Expando):
...
foo_reference = db.ReferecnceProperty(None, collection_name='foos')
...
The two definitions are in different files. I assign the reference the following way:
...
foo = Foo.query.get()
bar.foo_reference = ndb.Key.to_old_key(foo.key)
...
I have no problems doing this. I can see the entry stored in the database in the app engine dashboard, but when I try to access the foo_reference I get a 'No implementation for kind Foo' exception. The problem line looks like this: foo = bar.foo_reference.get()
I have doble checked all my imports and can actually create a Foo entity where I try to access the entity. Is there some restriction in the db reference properties for referencing ndb? How do I fix this issue?
回答1:
Your Bar and Foo classes need to be imported. until you have imported them, the underlying mechanism for retrieving entities and recreating instances of the Models can't find the Class. Importing them creates a registry of class to entity's.
May be the path to the handler with the query isn't importing the models.
Looking further at your code, you are also mixing db and ndb, plus you have lots of typo's, and why are you using ndb.Key.to_old_key if you are using db
for model definition rather than nbd, or is that another typo.
来源:https://stackoverflow.com/questions/16781435/no-implementation-for-kind-exception-python-google-app-engine