Python 谷歌应用程序引擎-获取父密钥或祖先';s路径';s属性
我的数据结构如下:Python 谷歌应用程序引擎-获取父密钥或祖先';s路径';s属性,python,google-app-engine,google-cloud-datastore,Python,Google App Engine,Google Cloud Datastore,我的数据结构如下: Restaurant > Menu > Category > Dish 当我加载餐厅的每道菜时,使用: q = db.Query(Dish) q.ancestor('Restaurant Key') 我希望每道菜都有一条路径,路径上有每个祖先的财产“名称”: dish.path = "Cheesecake Factory > Meals > Beefs > Beef with Potatoes" 我知道dish.to_path(),但
Restaurant > Menu > Category > Dish
当我加载餐厅的每道菜时,使用:
q = db.Query(Dish)
q.ancestor('Restaurant Key')
我希望每道菜都有一条路径,路径上有每个祖先的财产“名称”:
dish.path = "Cheesecake Factory > Meals > Beefs > Beef with Potatoes"
我知道dish.to_path(),但这只返回祖先的实体种类。如果您使用对象的名称作为键、id(“Cheescake Factory”、“Founds”、“Beefs”等),这是可能的 dish.key().to_path()应为您提供格式为[等祖父母种类、祖父母姓名/id、父母种类、父母姓名/id、种类、姓名/id>]的列表 但是,如果对象的名称不是键,则必须获取每个祖先对象才能获得名称。在这种情况下,最好将整个路径作为字符串存储在dish实体中,以便保存数据存储回迁