多对多关系 +谷歌数据存储 + Python
给出以下日志:
Restaurant = <persistence.model.Restaurant object at 0x3913c01e89e78a20>
Review Content = This is my first comment...
User[0] = <persistence.model.User object at 0x3913c01e89e780a0>
和以下代码:
class RestaurantReview(db.Model):
owned_by = db.ReferenceProperty(Restaurant, required=True, collection_name='restaurant')
written_by = db.ReferenceProperty(User, required=True, collection_name='user')
content = db.StringProperty(required=True)
date = db.DateTimeProperty(auto_now_add=True)
当我尝试创建 RestaurantReview 实例时,它永远不会工作:
RestaurantReview(owned_by=restaurant, written_by=user[0], content=restaurant_review_content.__str__()).put()
编辑 知道发生了什么吗?它不断抛出我设置的自定义错误。
try:
RestaurantReview(owned_by=restaurant, written_by=user[0], content=restaurant_review_content.__str__()).put()
except:
logging.error('CUSTOM ERROR: Review for restaurant has not been added')
Given the log of following:
Restaurant = <persistence.model.Restaurant object at 0x3913c01e89e78a20>
Review Content = This is my first comment...
User[0] = <persistence.model.User object at 0x3913c01e89e780a0>
and following codes:
class RestaurantReview(db.Model):
owned_by = db.ReferenceProperty(Restaurant, required=True, collection_name='restaurant')
written_by = db.ReferenceProperty(User, required=True, collection_name='user')
content = db.StringProperty(required=True)
date = db.DateTimeProperty(auto_now_add=True)
When I was trying to create the instance of RestaurantReview, it just never work:
RestaurantReview(owned_by=restaurant, written_by=user[0], content=restaurant_review_content.__str__()).put()
EDIT
Any idea what's happening? It keeps throwing the custom error that I set.
try:
RestaurantReview(owned_by=restaurant, written_by=user[0], content=restaurant_review_content.__str__()).put()
except:
logging.error('CUSTOM ERROR: Review for restaurant has not been added')
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我建议通过调用raise来重新抛出错误
I suggest to rethrow the error by calling raise