没有类别异常Python Google App Engine的实现 [英] No implementation for Kind Exception Python Google App Engine

查看:90
本文介绍了没有类别异常Python Google App Engine的实现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图从db Expando
子类访问一个ndb PolyModel子类的引用属性。我的两个类看起来像这样:

  class Foo(polymodel.PolyModel):
...

class Bar(db.Expando):
...
foo_reference = db.ReferecnceProperty(None,collection_name ='foos')
...

这两个定义在不同的文件中。
我通过以下方式分配引用:

  ... 
foo = Foo.query.get ()
bar.foo_reference = ndb.Key.to_old_key(foo.key)
...

我这样做没有问题。我可以在应用程序引擎仪表板中看到存储在数据库中的条目,但是当我尝试访问foo_reference时,我得到'没有实现Foo'的异常。问题行如下所示:
foo = bar.foo_reference.get()



我有doble检查了所有的导入,实际上可以创建一个Foo实体我尝试访问实体。
在引用ndb的数据库引用属性中是否存在一些限制?
我如何解决这个问题?

解决方案

您的Bar和Foo类需要导入。直到您导入它们,检索实体和重新创建模型实例的基本机制无法找到该类。
导入它们会创建一个类到实体的注册表。



可能是处理程序的路径,查询不会导入模型。



进一步研究你的代码,你也混合了db和ndb,再加上你有很多错字,如果你使用<$ c $,你为什么使用ndb.Key.to_old_key c> db 为模型定义而不是nbd,或者是另一个错字。

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?

解决方案

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.

这篇关于没有类别异常Python Google App Engine的实现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆