diff --git a/appengine/standard/ndb/schema_update/main.py b/appengine/standard/ndb/schema_update/main.py index 57ec3d99b10..fa5e2d05834 100644 --- a/appengine/standard/ndb/schema_update/main.py +++ b/appengine/standard/ndb/schema_update/main.py @@ -20,7 +20,7 @@ populate these new fields onto entities that existed prior to adding the new fields to the model class. """ - +# [START imports] import logging import os @@ -38,8 +38,10 @@ os.path.join(os.path.dirname(__file__), 'templates')), extensions=['jinja2.ext.autoescape'], autoescape=True) +# [END imports] +# [START display_entities] class DisplayEntitiesHandler(webapp2.RequestHandler): """Displays the current set of entities and options to add entities or update the schema.""" @@ -54,8 +56,10 @@ def get(self): template = JINJA_ENVIRONMENT.get_template('index.html') self.response.write(template.render(template_values)) +# [END display_entities] +# [START add_entities] class AddEntitiesHandler(webapp2.RequestHandler): """Adds new entities using the v1 schema.""" def post(self): @@ -71,8 +75,10 @@ def post(self): self.response.write(""" Entities created. View entities. """) +# [END add_entities] +# [START update_schema] class UpdateSchemaHandler(webapp2.RequestHandler): """Queues a task to start updating the model schema.""" def post(self): @@ -123,6 +129,7 @@ def update_schema_task(cursor=None, num_updated=0, batch_size=100): logging.debug( 'update_schema_task complete with {0} updates!'.format( num_updated)) +# [END update_schema] app = webapp2.WSGIApplication([ diff --git a/appengine/standard/ndb/schema_update/models_v1.py b/appengine/standard/ndb/schema_update/models_v1.py index ea84bc9b869..92924788d42 100644 --- a/appengine/standard/ndb/schema_update/models_v1.py +++ b/appengine/standard/ndb/schema_update/models_v1.py @@ -15,6 +15,8 @@ from google.appengine.ext import ndb +# [START models_v1] class Picture(ndb.Model): author = ndb.StringProperty() name = ndb.StringProperty(default='') +# [END models_v1] diff --git a/appengine/standard/ndb/schema_update/models_v2.py b/appengine/standard/ndb/schema_update/models_v2.py index 8f2c79ff3c6..bc3952d742b 100644 --- a/appengine/standard/ndb/schema_update/models_v2.py +++ b/appengine/standard/ndb/schema_update/models_v2.py @@ -15,9 +15,11 @@ from google.appengine.ext import ndb +# [START models_v2] class Picture(ndb.Model): author = ndb.StringProperty() name = ndb.StringProperty(default='') # Two new fields num_votes = ndb.IntegerProperty(default=0) avg_rating = ndb.FloatProperty(default=0) +# [END models_v2]