Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/google-app-engine/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python中@Named API参数的等效项_Python_Google App Engine_Rest_Google Cloud Endpoints - Fatal编程技术网

Python中@Named API参数的等效项

Python中@Named API参数的等效项,python,google-app-engine,rest,google-cloud-endpoints,Python,Google App Engine,Rest,Google Cloud Endpoints,是否有任何方法可以在Python中使用命名方法参数-对应于此Java示例: @ApiMethod( name = "foos.remove", path = "foos/{id}", httpMethod = HttpMethod.DELETE, ) public void removeFoo(@Named("id") String id) { } 在我的Python版本中,如果我将@endpoints.method路径设置为foos/{id},URL将正确匹配,但是如

是否有任何方法可以在Python中使用命名方法参数-对应于此Java示例:

@ApiMethod(
    name = "foos.remove",
    path = "foos/{id}",
    httpMethod = HttpMethod.DELETE,
)
public void removeFoo(@Named("id") String id) {
}

在我的Python版本中,如果我将
@endpoints.method
路径设置为
foos/{id}
,URL将正确匹配,但是如何访问参数?

没有严格的等价项,但是如果
{id}
在您的路径中,然后在方法中用于请求类的
protorpc
消息类中必须有一个名为
id
的字段

例如:

from google.appengine.ext import endpoints
from protorpc import messages
from protorpc import remote

class MyMessageClass(messages.Message):
  id = messages.StringField(1)  # Or any other field type

@endpoints.api(...)
class MyApi(remote.Service):
  @endpoints.method(MyMessageClass, SomeResponseClass,
                    ..., path='foos/{id}')
  def my_method(self, request):
    ...

它应该只是方法的第一个参数。@Linuxios不适用于Python实现。这很有效,谢谢!如果在文档中提到它就好了。