在 Google App Engine 中将模型转换为 PolyModel
如果在数据存储中已存储实体后将模型的基类从 db.Model 切换到 db.PolyModel(您决定要添加多态性),会产生什么后果?
另外,是否有任何理由不总是将模型创建为 PolyModel,以便子类化永远不是问题?
What are the consequences if you switch a model's base class from db.Model to db.PolyModel (You decide you want to add polymorphism) after it already has entities stored in the datastore?
Also, is there any reason not to always create your models as PolyModels, so subclassing is never an issue?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
至于您的第一个问题,这似乎不是问题,因为更改模式基础class 是 Google 记录的删除属性的方法。
我相信 PolyModel 在访问属性时有一些隐藏成本,这就是为什么您应该从模型开始并仅在必要时进行切换。
As for you for your first question, it doesn't seem like an issue, since changing modal base class is a documented way to remove properties by Google.
I believe that PolyModel has some hidden cost when accessing the properties, this is why you should start with Model and switch only if necessary.