python - @EndpointsAliasProperty and @Model.query_method causes BadRequestError(Key path element must not be incomplete:...) -
hey right i'm developing backend api using google protorpc , endpoints. i'm using endpoints-proto-datastore
library.
so strange things happen here, here endpointsmodel
class
class assetdata(endpointsmodel): type = msgprop.enumproperty(assettype, indexed=true) def auth_id_set(self, value): if applicationid.get_by_id(value) none: raise endpoints.unauthorizedexception('no auth_id') self._auth_id = value @endpointsaliasproperty(required=true, setter=auth_id_set, property_type=messages.integerfield) def auth_id(self): return self._auth_id def app_id_set(self, value): if applicationid.query(applicationid.app_id == value).get() none: raise endpoints.unauthorizedexception('wrong app_id') self._app_id = value if self.check_auth_app_id_pair(self.auth_id, value): self._app_id = value else: raise endpoints.badrequestexception('auth_id , app_id mismatch') @endpointsaliasproperty(required=true, setter=app_id_set) def app_id(self): return self._app_id @staticmethod def check_auth_app_id_pair(authen_id, applic_id): dat = applicationid.get_by_id(authen_id) if dat.app_id != applic_id: return false else: return true
and api class
@endpoints.api(...) class assetdatabaseapi(remote.service): @assetdata.query_method(query_fields=('limit', 'order', 'pagetoken', 'type', 'auth_id', 'app_id'), path='assets', http_method='get', name='assets.getassetmultiple') def assets_get_multiple(self, query): return query
when deploy this, everytime tried access assets.getmultipleassets
gives me error raised badrequesterror(key path element must not incomplete: [applicationid: ])
. strangely enough happen method using @model.query_method
, have other methods using same system using @model.method
, runs ok.
if tried in development server, gives me runtimeerror: badrequesterror('missing key id/name',)
if re-save .py file , retry it, work (sometimes not , re-save can make error happens again).
can tell me mistake? thanks
i think problem how call method - it's static method, have access through class, not instance (self):
if assetdata.check_auth_app_id_pair(self.auth_id, value): self._app_id = value else: raise endpoints.badrequestexception('auth_id , app_id mismatch')
Comments
Post a Comment