1212# See the License for the specific language governing permissions and
1313# limitations under the License.
1414
15- # [START all ]
15+ # [START gae_ndb_redis_cache ]
1616import logging
1717
1818from flask import Flask , redirect , render_template , request
3333 global_cache = None
3434
3535
36- # [START greeting ]
36+ # [START gae_ndb_redis_cache_greeting ]
3737class Greeting (ndb .Model ):
3838 """Models an individual Guestbook entry with content and date."""
3939
4040 content = ndb .StringProperty ()
4141 date = ndb .DateTimeProperty (auto_now_add = True )
42- # [END greeting ]
42+ # [END gae_ndb_redis_cache_greeting ]
4343
44- # [START query ]
44+ # [START gae_ndb_redis_cache_query ]
4545 with client .context (global_cache = global_cache ):
4646
4747 @classmethod
@@ -56,7 +56,7 @@ def display_guestbook():
5656 with client .context (global_cache = global_cache ):
5757 ancestor_key = ndb .Key ("Book" , guestbook_name or "*notitle*" )
5858 greetings = Greeting .query_book (ancestor_key ).fetch (20 )
59- # [END query ]
59+ # [END gae_ndb_redis_cache_query ]
6060
6161 greeting_blockquotes = [greeting .content for greeting in greetings ]
6262 return render_template (
@@ -66,7 +66,7 @@ def display_guestbook():
6666 )
6767
6868
69- # [START submit ]
69+ # [START gae_ndb_redis_cache_submit ]
7070@app .route ("/sign" , methods = ["POST" ])
7171def update_guestbook ():
7272 # We set the parent key on each 'Greeting' to ensure each guestbook's
@@ -81,12 +81,12 @@ def update_guestbook():
8181 content = request .form .get ("content" , None ),
8282 )
8383 greeting .put ()
84- # [END submit ]
84+ # [END gae_ndb_redis_cache_submit ]
8585
8686 return redirect ("/?" + urlencode ({"guestbook_name" : guestbook_name }))
8787
8888
8989if __name__ == "__main__" :
9090 # This is used when running locally.
9191 app .run (host = "127.0.0.1" , port = 8080 , debug = True )
92- # [END all ]
92+ # [END gae_ndb_redis_cache ]
0 commit comments