简体   繁体   English

Google App引擎-端点

[英]Google app engine - endpoints

Hy I have a question about Google Endpoints when trying to create an Endpoints model method like this: 当我尝试创建这样的Endpoints模型方法时,我对Google Endpoints有一个疑问:

@DataPoint.method(request_fields=('id',),
                      path='datapoint/{id}',
                      http_method='GET',
                      name='datapoint.get')
    def datapoint_get(self, datapoint):
        if not datapoint.from_datastore:
                raise endpoints.NotFoundException('Datapoint not found.')
        return datapoint

I also have the "_message_fields_schema" overwritten in the model itself: 我还用模型本身覆盖了“ _message_fields_schema”:

_message_fields_schema = ('id', 'id_datapoint', 'created')

My question is why can't i replace the "id" with "id_datapoint" in "request_fields" and "path" ? 我的问题是为什么我不能在“ request_fields”和“ path”中将“ id”替换为“ id_datapoint”? I know it can be done by a simple query method, but I'd just like to know why the above doesn't work. 我知道可以通过一种简单的查询方法来完成此操作,但是我只是想知道为什么上述方法不起作用。

Thanks ! 谢谢 !

So the solution was pretty dumb...I had a model in models.py which was named DataPointModelCollection, so when endpoints generated the library there was a conflict, because it wanted to create the DataPointModelCollection class, but it was already existing. 因此,解决方案非常笨拙……我在models.py中有一个名为DataPointModelCollection的模型,因此当端点生成库时会发生冲突,因为它想创建DataPointModelCollection类,但该类已经存在。 The problem was solved by renaming my existing entity to DataPointModelCollectionList. 通过将现有实体重命名为DataPointModelCollectionList,解决了该问题。 There was no overlapping between entities after that and the class contained all the methods needed to retrieve specific List. 此后,实体之间没有重叠,并且该类包含检索特定List所需的所有方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM