Skip to content

Datastore update schema tags #521

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Sep 14, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion appengine/standard/ndb/schema_update/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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."""
Expand All @@ -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):
Expand All @@ -71,8 +75,10 @@ def post(self):
self.response.write("""
Entities created. <a href="/">View entities</a>.
""")
# [END add_entities]


# [START update_schema]
class UpdateSchemaHandler(webapp2.RequestHandler):
"""Queues a task to start updating the model schema."""
def post(self):
Expand Down Expand Up @@ -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([
Expand Down