1

我在部署的 appengine 应用程序上遇到了一个问题:它没有使用 Google 的 API 资源管理器返回我的位置。

我确实定义了一个 ./datastore_models/location.py 文件:

#!/usr/bin/env python
# -*- coding: utf-8 -*-

from google.appengine.ext import ndb
from google.appengine.api import search
from endpoints_proto_datastore.ndb import EndpointsModel

class Location(EndpointsModel):
    name = ndb.StringProperty(required=True, verbose_name="Name")
    description = ndb.TextProperty(required=True, verbose_name="Description")
    address = ndb.StringProperty(required=True, verbose_name="Address")
    coordinate = ndb.GeoPtProperty(required=False, verbose_name="Coordinate")
    enable_geocode = ndb.BooleanProperty(default=False, verbose_name="Enable geocode")
    active = ndb.BooleanProperty(default=True, verbose_name="Active")
    owner = ndb.UserProperty(required=False, verbose_name="Owner")

我确实有一个简单的 ./main.py 文件:

#!/usr/bin/env python
# -*- coding: utf-8 -*-

import endpoints
from protorpc import remote
from datastore_models.location import Location

WEB_CLIENT_ID = 'ID.apps.googleusercontent.com'

@endpoints.api(name='uemd', version='v1',
               description='API for locations, objects and events',
               audiences=[WEB_CLIENT_ID, endpoints.API_EXPLORER_CLIENT_ID])
class UemDAPI(remote.Service):
    @Location.method(user_required=True, request_fields=('name', 'description', 'address', 'enable_geocode'),
                     path='location', http_method='POST', name='location.insert')
    def LocationInsert(self, location):
        location.owner = endpoints.get_current_user()
        location.put()
        return location

    @Location.method(user_required=True, request_fields=('id',),
                     path='location/{id}', http_method='GET', name='location.get')
    def LocationGet(self, location):
        if not location.from_datastore:
            raise endpoints.NotFoundException('Location not found.')
        return location

    @Location.query_method(user_required=True, query_fields=('active', 'limit', 'order', 'pageToken'),
                           path='locations', name='location.list')
    def LocationList(self, query):
        return query.filter(Location.owner == endpoints.get_current_user())

app = endpoints.api_server([UemDAPI], restricted=False)

当我现在调用“GET https://uemd-core.appspot.com/_ah/api/uemd/v1/locations ”时,我没有收到我在使用 POST 方法之前创建的位置。我只是收到:

{
 "kind": "uemd#locationItem",
 "etag": "\"llW4_dZC50NEF69z_hZurfpZb1s/wnbopBN8xedxeOulX5Nry_3uwCw\""
}

执行“GET https://uemd-core.appspot.com/_ah/api/uemd/v1/location/5634387206995968 ”确实会按预期返回一个位置。

在 Appengine 日志中,我看到以下调试消息:

id_token verification failed: Can't parse header:ɭ�

但我也看到了返回单个位置的方法的这条消息......

在 dev_appserver.py 上运行相同的查询会引发:

RuntimeError: UnicodeDecodeError('utf8', "id_token verification failed: Can't parse header: \xc9\xad\xbd", 52, 53, 'invalid start byte')

到目前为止,我确实遵循了 endpoints-proto-datastore 的示例,但我确实想将我的数据存储模型存储在一个额外的目录 (datastore_models) 中。location.insert 和 location.get 方法有效,但 location.list 无效。所有这些方法都显示“无法解析标题”消息......我该如何解决这个问题?

干杯

我仍然有同样的问题。检索一个位置确实有效,而多个则无效。

Traceback (most recent call last):
  File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/cherrypy/cherrypy/wsgiserver/wsgiserver2.py", line 1302, in communicate
    req.respond()
  File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/cherrypy/cherrypy/wsgiserver/wsgiserver2.py", line 831, in respond
    self.server.gateway(self).respond()
  File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/cherrypy/cherrypy/wsgiserver/wsgiserver2.py", line 2115, in respond
    response = self.req.server.wsgi_app(self.env, self.start_response)
  File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/devappserver2/wsgi_server.py", line 269, in __call__
    return app(environ, start_response)
  File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/devappserver2/request_rewriter.py", line 311, in _rewriter_middleware
    response_body = iter(application(environ, wrapped_start_response))
  File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/devappserver2/python/request_handler.py", line 148, in __call__
    self._flush_logs(response.get('logs', []))
  File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/devappserver2/python/request_handler.py", line 284, in _flush_logs
    apiproxy_stub_map.MakeSyncCall('logservice', 'Flush', request, response)
  File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/api/apiproxy_stub_map.py", line 94, in MakeSyncCall
    return stubmap.MakeSyncCall(service, call, request, response)
  File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/api/apiproxy_stub_map.py", line 328, in MakeSyncCall
    rpc.CheckSuccess()
  File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/api/apiproxy_rpc.py", line 156, in _WaitImpl
    self.request, self.response)
  File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/ext/remote_api/remote_api_stub.py", line 200, in MakeSyncCall
    self._MakeRealSyncCall(service, call, request, response)
  File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/ext/remote_api/remote_api_stub.py", line 234, in _MakeRealSyncCall
    raise pickle.loads(response_pb.exception())
RuntimeError: UnicodeDecodeError('utf8', "id_token verification failed: Can't parse header: \xc9\xad\xbd", 52, 53, 'invalid start byte')
4

1 回答 1

0

这与 endpoints-proto-datastore 无关。这是 googleappengine 的一个问题,似乎它将在下一个版本(1.8.9)中得到修复:

https://code.google.com/p/googleappengine/issues/detail?id=10285

干杯

于 2013-12-28T14:36:04.943 回答