访问 django 外部的表时出现 appengine KindError
我在 home/models.py 中有一个名为 Mytable 的表并使用 django aep 我引用的是 Mytable.all()。
它在数据查看器中显示为 home_mytable
现在,对于 app.yaml 中的某些 url,我有一个单独的处理程序 处理这些请求。 (这实际上是谷歌浪潮 机器人处理程序)。
在此处理程序中,我想引用表 home_mytable 我通过调用 db.GqlQuery("SELECT * from home_mytable") 来做到这一点,
但是发生了一些奇怪的事情。我收到一个 KindError 没有实现 home_mytable
我偶尔收到这个,有时它只是工作 好吧,我怀疑在我调用一个网址后就会发生这种情况 从 django 处理程序引用此表。
我的问题是,我怎样才能 a) 确保不会发生此错误并且 b) 以编程方式检查可用的内容 “种类”是这样我可以尝试调试这个
I have a table called Mytable in home/models.py and using django aep
I reference is as Mytable.all().
It shows up in the Data Viewer as home_mytable
Now, for some urls within app.yaml I have a separate handler
that processes these requests. (This is in fact a google wave
robot handler).
Within this handler I want to reference the table home_mytable
I do so by calling db.GqlQuery("SELECT * from home_mytable")
However something strange happens. I receive a KindError
No implementation for kind home_mytable
I receive this sporadically though, sometimes It works just
fine, I suspect that happens right after I call up a url
that references this table from a django handler.
My questions are, how can I
a) ensure that this error doesnt occur and
b) programattically check what the available
'kinds' are so I can try and debug this
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
App Engine 补丁猴子补丁您的模型以具有不同的名称。不要问我为什么,但这就是它的作用。要修复问题,您需要重写模型中的 kind() 类方法,以确保它们始终具有“固定”种类名称,如下所示:
App Engine Patch monkeypatches your models to have different kind names. Don't ask me why, but that's what it does. To fix things, you need to override the kind() class method in your models to make sure they always have the 'fixed' kind names, like this: