Sas*_*sxa 30 python google-app-engine protorpc google-cloud-endpoints endpoints-proto-datastore
protorpc当我使用端点时,我会收到一些奇怪的错误.在这段代码中:
class Application(EndpointsModel):
_message_fields_schema = ('id', 'name')
created = ndb.DateTimeProperty(auto_now_add=True)
name = ndb.StringProperty()
roles = ndb.IntegerProperty(repeated=True)
updated = ndb.DateTimeProperty(auto_now=True)
owner = ndb.KeyProperty(kind='User')
@API.api_class(resource_name="application")
class ApplicationApi(protorpc.remote.Service):
@Application.method(http_method="GET",
request_fields=('id',),
name="get",
path="applications/{id}")
def ApplicationGet(self, instance):
if not instance.from_datastore:
raise endpoints.NotFoundException("Application not found.")
return instance
@Application.query_method(http_method="GET",
query_fields=('limit', 'order', 'pageToken'),
name="list",
path="applications")
def ApplicationList(self, query):
return query
Run Code Online (Sandbox Code Playgroud)
当我调用application.get()错误时如下:( 完全跟踪):
TypeError:只能从确切类型为Application的实体进行复制.收到了一个Application实例.
并且调用application.list()错误如下:( 完全跟踪):
ValidationError:
<class '.Application'>找到的字段项的预期类型<Application name: u'test'>(类型<class '.Application'>)
可能是什么导致了这个?我的其他模型具有几乎相同的代码(只是不同的属性)工作正常.
| 归档时间: |
|
| 查看次数: |
801 次 |
| 最近记录: |