Python endpoints协议数据存储:如何忽略EndpointSaliaProperty setters中的必填字段?

Python endpoints协议数据存储:如何忽略EndpointSaliaProperty setters中的必填字段?,python,google-app-engine,endpoints-proto-datastore,Python,Google App Engine,Endpoints Proto Datastore,我有两个类:GameSession和Location。每个游戏会话都应该有一个位置集 class Location(EndpointsModel): _message_fields_schema = ('entityKey', 'name', 'description', 'address') name = ndb.StringProperty(required=True) description = ndb.TextProperty() address = n

我有两个类:GameSession和Location。每个游戏会话都应该有一个位置集

class Location(EndpointsModel):
    _message_fields_schema = ('entityKey', 'name', 'description', 'address')

    name = ndb.StringProperty(required=True)
    description = ndb.TextProperty()
    address = ndb.StringProperty()


class GameSession(EndpointsModel):
    _message_fields_schema = ('entityKey', 'name', 'description', 'location')

    name = ndb.StringProperty(required=True)
    description = ndb.TextProperty()
    location_key = ndb.KeyProperty(kind=Location, required=True)

    def location_setter(self, value):
        self.location_key = ndb.Key(urlsafe=value.entityKey)

    @EndpointsAliasProperty(setter=location_setter, property_type=Location.ProtoModel())
    def location(self):
        return self.location_key.get()
当我试图通过Google的API Explorer创建新游戏会话时,我收到以下错误消息:

Error parsing ProtoRPC request (Unable to parse request content: Message Location is missing required field name)
对gamesession的POST请求如下所示:

{
 "name": "aaa",
 "location": {
  "entityKey": "ahRkZXZ-Z2FtZXNlc3Npb24tY29yZXIVCxIITG9jYXRpb24YgICAgIDArwoM"
 }
}
我如何创建GameSession条目,而只需指定位置的entityKey?我只想存储密钥,这就是我不想询问姓名的原因。

问题在于:

 _message_fields_schema = ('entityKey', 'name', 'description', 'location')
具体来说,“entityKey”不应该存在。你可以用这样的东西来掩盖你的钥匙

def IdSet(self, value):
    if not isinstance(value, basestring):
        raise TypeError('ID must be a string.')
    self.UpdateFromKey(ndb.Key(Location, value))

@EndpointsAliasProperty(setter=IdSet, required=True)
def game_session(self):
    if self.key is not None:
        return self.key.string_id()
然后将(消息)字段(模式)更改为:

_message_fields_schema = ('name', 'description', 'game_session', 'address')
游戏会话将在何处设置并通过键获取游戏ID