Question

So I stumbled on EndpointsModel as a means of creating models. When I look online, there is basically no tutorial about it. For people who have used it, what's the advantage? Instead of ndb.Model I mean.

Edit:

Also, I tried to mimic the code at What is the best way to auth, identify and store delicate information about users? just to check it out, but my eclipse red-lines it:

from endpoints_proto_datastore.ndb import EndpointsModel
Was it helpful?

Solution

The Endpoints Proto Datastore API is not an official part of the App Engine SDK, but a library I have been working on.

It is documented and I'm happy to come on here and answer your questions. As it turns out, EndpointsModel is a subclass of ndb.Model, so you are getting the best of both worlds:

>>> from endpoints_proto_datastore.ndb import EndpointsModel
>>> from google.appengine.ext import ndb
>>> EndpointsModel.__bases__ == (ndb.Model,)
True

As mentioned on the docs landing page, the advantage is that the library:

...allows existing model classes to be used with Google Cloud Endpoints. By extending the functionality provided by ndb.Model class and the endpoints library, this library allows you to directly interact with model entities in your API methods rather than ProtoRPC requests.

We have also given a talk on using the library. In it, we explicitly mention that you'll need to add the endpoints_proto_datastore library to your application.

$ cd path/to/your/application/code
$ wget https://endpoints-proto-datastore.googlecode.com/files/endpoints_proto_datastore.zip
$ unqip -q endpoints_proto_datastore.zip
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top