Skip to content

Commit bd90f9d

Browse files
committed
minor Mod22 tweaks
1 parent fde3f18 commit bd90f9d

File tree

8 files changed

+19
-9
lines changed

8 files changed

+19
-9
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ Topic | Module ordering | Description
7676
--- | --- | ---
7777
Baseline | 0 ⇒ 1 | Not a migration but a description of the baseline application (review this material before doing any migrations)
7878
Web framework | 1 ⇒ _everything else_ | Current App Engine runtimes do not come with a web framework, so this must be the first migration performed. All migrations below can be performed after this one.
79-
Bundled services | 17 | This module is for Python bundled services users interested in how to access those services from Python 3.
79+
Bundled services | 17 ⇒ 22 | These modules are for those who want to continue using Python bundled services from Python 3 App Engine.
8080
Datastore | 2 [⇒ 3 [⇒ 6]] | Moving off App Engine `ndb` makes your apps more portable, so the **Module 2** Cloud NDB migration is _recommended_. **Module 3:** Migrating to Cloud Datastore (Firestore in Datastore mode) is _optional_ and only recommended if you have other code using Cloud Datastore. **Module 6**: Migrating to Cloud Firestore (Native mode) is generally _not recommended_ unless you must have the Firebase features it has, and those features will eventually be integrated into Cloud Datastore.
8181
(Push) Task Queues | [7 ⇒] 8 [⇒ 9] | Moving off App Engine `taskqueue` makes your apps more portable, so the **Module 8** Cloud Tasks migration is _recommended_ for those using push tasks. Those unfamiliar with push tasks should do **Module 7** first to add push tasks to the sample app. **Module 9:** Migrating to Cloud Datastore (Firestore in Datastore mode), Cloud Tasks (v2), and Python 3 is _optional_ and only recommended if you have other code using Cloud Datastore and considering upgrading to Python 3.
8282
(Pull) Task Queues | [18 ⇒] 19 | Moving off App Engine `taskqueue` makes your apps more portable, so the **Module 19** Cloud Pub/Sub migration is _recommended_ for those using pull tasks. The app is also ported to Python 3. Those unfamiliar with pull tasks should do **Module 18** first to add pull tasks to the sample app.
@@ -119,7 +119,7 @@ Module | Topic | Video | Codelab | START here | FINISH here
119119
19|Migrate to Cloud Pub/Sub| _TBD_ | [link](https://codelabs.developers.google.com/codelabs/cloud-gae-python-migrate-19-pubsub?utm_source=codelabs&utm_medium=et&utm_campaign=CDR_wes_aap-serverless_mgrpubsub_sms_202016&utm_content=-) | Module 18 [code](/mod18-gaepull) (2.x) | Module 19 [code](/mod19-pubsub) (2.x & 3.x)
120120
20|Add App Engine `users` | _TBD_ | [link](https://codelabs.developers.google.com/codelabs/cloud-gae-python-migrate-20-gaeusers?utm_source=codelabs&utm_medium=et&utm_campaign=CDR_wes_aap-serverless_mgrgaeusers_sms_202119&utm_content=-)| Module 1 [code](/mod1-flask) (2.x) | Module 20 [code](/mod20-gaeusers) (2.x)
121121
21|Migrate to Cloud Identity Platform | _TBD_ | [link](https://codelabs.developers.google.com/codelabs/cloud-gae-python-migrate-21-idenplat?utm_source=codelabs&utm_medium=et&utm_campaign=CDR_wes_aap-serverless_mgridenplat_sms_202119&utm_content=-)| Module 20 [code](/mod20-gaeusers) (2.x) | Module 21 [code](/mod21a-idenplat) (2.x) & [code](/mod21b-idenplat) (3.x)
122-
22|Migrate to Python 3 bundled services (Part 2)| _TBD_ | _N/A_ | Module 22 [code](/mod22-bundled) (2.x & 3.x) | _(same)_
122+
22|Migrate to Python 3 bundled services (Part 2)| _TBD_ | _N/A_ | Module 22 [code](/mod22-bundled) (2.x & 3.x) | _(⇐ same folder)_
123123

124124

125125
### Table of contents

mod22-bundled/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
There are six folders in this directory that contain full applications using the Blobstore, Deferred, and Mail bundled services. A Python 2 version using the `webapp2` framework is provided along with a modernized Python 3 equivalent using the Flask web framework and the Python 3 App Engine SDK.
44

5-
Bundled service | Python 2 `webapp` | Python 3 Flask
5+
Bundled service | Python 2 `webapp2` | Python 3 Flask
66
--- | --- | ---
77
Blobstore | [code](blobstore2) | [code](blobstore3)
88
Deferred | [code](deferred2) | [code](deferred3)

mod22-bundled/blobstore2/main.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
from google.appengine.ext.webapp import blobstore_handlers
1818

1919
UPLOAD_FORM = '''\
20+
<title>Module 22 Blobstore sample app</title>
2021
<h2>Upload photo:</h2>
2122
<form action="%s" method="POST" enctype="multipart/form-data">
2223
<input type="file" name="file"><p></p><input type="submit">

mod22-bundled/blobstore3/main.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
from google.appengine.ext import blobstore, ndb
1818

1919
UPLOAD_FORM = '''\
20+
<title>Module 22 Blobstore sample app</title>
2021
<h2>Upload photo:</h2>
2122
<form action="%s" method="POST" enctype="multipart/form-data">
2223
<input type="file" name="file"><p></p><input type="submit">

mod22-bundled/deferred2/main.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616
from google.appengine.ext import deferred, ndb
1717

1818
KEY_NAME = 'SECRET'
19+
OUTPUT = '''\
20+
<title>Module 22 Deferred sample app</title>
21+
Counter at %d... bump requested.
22+
'''
1923

2024
class Counter(ndb.Model):
2125
'Counter entity: autoincrement integer'
@@ -33,8 +37,7 @@ class MainHandler(webapp2.RequestHandler):
3337
def get(self):
3438
'main application (GET) handler'
3539
entity = Counter.get_by_id(KEY_NAME)
36-
self.response.write('Counter at %d... bump requested.' % (
37-
entity.count if entity else 0))
40+
self.response.write(OUTPUT % (entity.count if entity else 0))
3841
deferred.defer(bump_counter_later, KEY_NAME)
3942

4043

mod22-bundled/deferred3/main.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@
1717
from google.appengine.ext import deferred, ndb
1818

1919
KEY_NAME = 'SECRET'
20+
OUTPUT = '''\
21+
<title>Module 22 Deferred sample app</title>
22+
Counter at %d... bump requested.
23+
'''
2024
app = Flask(__name__)
2125
app.wsgi_app = wrap_wsgi_app(app.wsgi_app, use_deferred=True)
2226

@@ -36,7 +40,6 @@ def bump_counter_later(key):
3640
def root():
3741
'main application (GET) handler'
3842
entity = Counter.get_by_id(KEY_NAME)
39-
output = 'Counter at %d... bump requested.' % (
40-
entity.count if entity else 0)
43+
output = OUTPUT % (entity.count if entity else 0)
4144
deferred.defer(bump_counter_later, KEY_NAME)
4245
return output

mod22-bundled/mail2/main.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
KEY_NAME = 'SECRET'
2121
FIELDS = frozenset(('sender', 'subject', 'date'))
2222
MSG_TMPL = '''\
23+
<title>Module 22 Mail sample app</title>
2324
<h2>Last message received:</h2><p></p>
2425
<pre>
2526
From: %(sender)s
@@ -66,8 +67,8 @@ class MainHandler(webapp2.RequestHandler):
6667
def get(self):
6768
last_msg = LastMsg.get_by_id(KEY_NAME)
6869
msg_dict = last_msg.to_dict()
69-
self.response.write(
70-
MSG_TMPL % dict((k, escape(msg_dict[k])) for k in msg_dict))
70+
self.response.write(MSG_TMPL %
71+
dict((k, escape(msg_dict[k])) for k in msg_dict))
7172

7273

7374
app = webapp2.WSGIApplication([

mod22-bundled/mail3/main.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
KEY_NAME = 'SECRET'
2121
FIELDS = frozenset(('sender', 'subject', 'date'))
2222
MSG_TMPL = '''\
23+
<title>Module 22 Mail sample app</title>
2324
<h2>Last message received:</h2><p></p>
2425
<pre>
2526
From: %(sender)s

0 commit comments

Comments
 (0)