迁移到高复制数据存储后,实体密钥不同 [英] Entity keys are different after migration to High Replication Datastore
问题描述
组,引脚和日志。每个 Group
实体都具有与其关联的Pin实体和/或Log实体,但关联不再在hrd中工作(这是迁移后仍然存在的),所以我的应用程序不再有效,我正在寻求帮助来恢复它。
下面我报告数据存储中前两个 Pin
实体的实体键。我在每一对的较短键中插入了一些空格,以便排列键以查看它们的相似性。请注意,所有键的开始和结束都是相似的,但MS与hrd不同。
解码的实体键:组:名称= 250cc >销:ID = 1个
实体#1 MS键:啊NzaW1wbGlmeWNvbm5lY3Rpb25zchkLEgVHcm91cCIFMjUwY2MMCxIDUGluGAEM
实体#1 HRD键:ahlzfnNpbXBsaWZ5Y29ubmVjdGlvbnMtaHJkchkLEgVHcm91cCIFMjUwY2MMCxIDUGluGAEM
解码实体键:组:名称= 250毫升> ;销:ID = 5001
实体#2 MS键:啊NzaW1wbGlmeWNvbm5lY3Rpb25zchoLEgVHcm91cCIFMjUwY2MMCxIDUGluGIknDA
实体#2 HRD键:ahlzfnNpbXBsaWZ5Y29ubmVjdGlvbnMtaHJkchoLEgVHcm91cCIFMjUwY2MMCxIDUGluGIknDA
要亲自查看应用,请使用此链接。您将看到名为Playground的 Group
>并查看它在URL中的调用方式。但是,出现的唯一标记(地图引脚)是从迁移到hrd以来添加的标记。
edit#0
以下是我的Python代码, code> Pin
其中父$ 组
。 elif action ==add:
pin = Pin(parent = place)
pin.name = self.request.get('details')
pin (self.request.get('lat'))
pin.lng = float(self.request.get('lng'))
pin.category = int(self.request .get('category'))
pin.label = self.request.get('label')
new_id = pin.put()
self.response.out.write(new_id )
以下是 Pin
。
$ $ p $ class Pin(db.Model):
date = db.DateTimeProperty(auto_now_add = True)
lat = db.FloatProperty()
lng = db.FloatProperty()
name = db.StringProperty()
cornerColor = db.StringProperty(default = 'ffffff')
height = db.InteProProperty(default = 32)
label = db.StringProperty(default ='')
labelColor = db.StringProperty(default ='000000')
labelSize = db.IntegerProperty(default = 2)
primaryColor = db.StringProperty(default ='ff0000')
shadowColor = db.StringProperty(default ='000000')
shape = db.StringProperty(default ='circle')
strokeColor = db.StringProperty(default ='000000')
width = db.InteProProperty(default = 32)
category = db.IntegerProperty (default = 0)
scategory = db.StringProperty()
logindex = db.InteProProperty(default = 0)
imageindex = db.InteProProperty(default = 0)
deleteRequested = db.BooleanProperty(default = False)
编辑#0
编辑#1
我的应用程序的问题与实体键无关,所有。相反,问题出在我尝试处理javascript / html中有关程式化标记的另一个弃用的Google(地图)功能。
我很抱歉这里有噪音。这个问题是由于我尝试作为javascript / html模板中的解决方法而尝试使用try..catch模式而导致无法使用/无法使用的。
编辑#1 编码的密钥字符串预计会改变。编码版本包含应用程序的Id。在迁移过程中,密钥将使用新的应用程序ID重新编写。
如果您将密钥存储为db.ReferenceProperty,那么在迁移过程中密钥会自动更新。
然而,如果您要存储字符串如
ahNzaW1wbGlmeWNvbm5lY3Rpb25zchkLEgVHcm91cCIFMjUwY2MMCxIDUGluGAEM
blockquote>
在db.StringProperty()(或其他类似的方式,例如URL的一部分)中,那么它们将不会被更新,您需要将自己更新为中描述的https://developers.google.com/appengine/docs/adminconsole/migration#migrating_serialized_datastore_keys =nofollow>。
您为Pin引用的模型似乎并未链接到其他实体,因此应该没有任何问题。
My migration to hrd is not working on appspot.com . The app datastore has 3 "kind"s of data in both the original master/slave (MS) and in the High Replication Datastore (hrd):
Group
, Pin, and Log. EachGroup
entity has Pin entities and/or Log entities associated with it, but the associations no longer work in the hrd (which is all that survives the migration), so my app no longer works and I am looking for help to revive it.Below I report the entity keys for the first two
Pin
entities in the datastore. I have inserted some spaces in the shorter key of each pair to facilitate lining up the keys to see their similarities. Notice that all the keys start and end similarly, but differ in MS vs hrd.Decoded entity key: Group: name=250cc > Pin: id=1 Entity #1 MS key: ah NzaW1wbGlmeWNvbm5lY3Rpb25zchkLEgVHcm91cCIFMjUwY2MMCxIDUGluGAEM Entity #1 hrd key: ahlzfnNpbXBsaWZ5Y29ubmVjdGlvbnMtaHJkchkLEgVHcm91cCIFMjUwY2MMCxIDUGluGAEM Decoded entity key: Group: name=250cc > Pin: id=5001 Entity #2 MS key: ah NzaW1wbGlmeWNvbm5lY3Rpb25zchoLEgVHcm91cCIFMjUwY2MMCxIDUGluGIknDA Entity #2 hrd key: ahlzfnNpbXBsaWZ5Y29ubmVjdGlvbnMtaHJkchoLEgVHcm91cCIFMjUwY2MMCxIDUGluGIknDA
To view the app yourself use this link. You will see the
Group
named "Playground" and see how it is called in the URL. However, the only markers (map pins) that appear are ones that were added since the migration to hrd.edit #0
Below is my Python code for adding saving a
Pin
where the parent is aGroup
.elif action == "add": pin = Pin(parent=place) pin.name = self.request.get('details') pin.lat = float(self.request.get('lat')) pin.lng = float(self.request.get('lng')) pin.category = int(self.request.get('category')) pin.label = self.request.get('label') new_id = pin.put() self.response.out.write(new_id)
And below is the class definition for
Pin
.class Pin(db.Model): date = db.DateTimeProperty(auto_now_add=True) lat = db.FloatProperty() lng = db.FloatProperty() name = db.StringProperty() cornerColor = db.StringProperty(default='ffffff') height = db.IntegerProperty(default=32) label = db.StringProperty(default='') labelColor = db.StringProperty(default='000000') labelSize = db.IntegerProperty(default=2) primaryColor = db.StringProperty(default='ff0000') shadowColor = db.StringProperty(default='000000') shape = db.StringProperty(default='circle') strokeColor = db.StringProperty(default='000000') width = db.IntegerProperty(default=32) category = db.IntegerProperty(default=0) scategory = db.StringProperty() logindex = db.IntegerProperty(default=0) imageindex = db.IntegerProperty(default=0) deleteRequested = db.BooleanProperty(default=False)
edit #0
edit #1
The problem with my app is not with the entity keys, after all. Instead, the problem is with the way I tried to handle another deprecated Google (Maps) feature regarding stylized markers in my javascript/html.
I am sorry for the noise here. The problem resulted from my inability/ineptness with a try..catch pattern I attempted to employ as a workaround in the javascript/html template.
edit #1
解决方案The encoded key strings are expected to change. The encoded version contain the application's Id. During the migration process the keys are re-written with the new application Id. References to keys are also similarly updated.
If you store a key as a db.ReferenceProperty, the key is automatically updated for you during the migration.
However if you are storing strings like
ahNzaW1wbGlmeWNvbm5lY3Rpb25zchkLEgVHcm91cCIFMjUwY2MMCxIDUGluGAEM
in db.StringProperty() (or other similar ways, such as a part of a URL), then they will not be updated an you need to update yourself as described in the docs.
The model you reference for Pin, does not appear to link to other entities so there shouldn't be any problems.
这篇关于迁移到高复制数据存储后,实体密钥不同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!