Book Image

Mastering Google App Engine

By : Mohsin Hijazee, Mohsin Shafique
Book Image

Mastering Google App Engine

By: Mohsin Hijazee, Mohsin Shafique

Overview of this book

Table of Contents (18 chapters)
Mastering Google App Engine
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Index

The model


We have been using ndb.Model so far, but didn't look at the class in detail. The following are the three groups of things that we need to look into:

  • The constructor

  • The class methods

  • The instance methods

Let's look at these in turn.

The constructor

We have been using constructor throughout our examples, as follows:

Listing(title="Civic 1995 for Sale")

What can you pass to the constructor? Basically, all the properties that you declared on the model itself can be supplied as keyword arguments for initial values while creating the instance. Besides this, the following can be supplied:

  • ID: This is either an integer or a string that you wish to use as an identifier instead of the autogenerated one using the id keyword argument. If an ID is provided, then the key cannot be specified. We have used it in some of our examples.

  • Key: You can specify the whole key yourself using the key keyword argument. If you are supplying the ndb.Key instance, the ID and parent cannot be supplied and should be...