Skip to content
This repository was archived by the owner on Oct 1, 2025. It is now read-only.

Commit 361568b

Browse files
committed
swap fetch_page() for fetch() OR visits are never empty refactor
1 parent fe0d94e commit 361568b

File tree

7 files changed

+7
-7
lines changed

7 files changed

+7
-7
lines changed

step0-webapp2-gaendb-py2/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def store_visit(remote_addr, user_agent):
2626

2727
def fetch_visits(limit):
2828
return (v.to_dict() for v in Visit.query().order(
29-
-Visit.timestamp).fetch_page(limit)[0])
29+
-Visit.timestamp).fetch(limit))
3030

3131
class MainHandler(webapp2.RequestHandler):
3232
def get(self):

step1-flask-gaendb-py2/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def store_visit(remote_addr, user_agent):
2626

2727
def fetch_visits(limit):
2828
return (v.to_dict() for v in Visit.query().order(
29-
-Visit.timestamp).fetch_page(limit)[0])
29+
-Visit.timestamp).fetch(limit))
3030

3131
@app.route('/')
3232
def root():

step2-flask-cloudndb-py2/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def store_visit(remote_addr, user_agent):
2929
def fetch_visits(limit):
3030
with ds_client.context():
3131
return (v.to_dict() for v in Visit.query().order(
32-
-Visit.timestamp).fetch_page(limit)[0])
32+
-Visit.timestamp).fetch(limit))
3333

3434
@app.route('/')
3535
def root():

step2-flask-cloudndb-py3/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def store_visit(remote_addr, user_agent):
2929
def fetch_visits(limit):
3030
with ds_client.context():
3131
return (v.to_dict() for v in Visit.query().order(
32-
-Visit.timestamp).fetch_page(limit)[0])
32+
-Visit.timestamp).fetch(limit))
3333

3434
@app.route('/')
3535
def root():

step4-cloudds-cloudrun-py3/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def fetch_visits(limit):
3535
@app.route('/')
3636
def root():
3737
store_visit(request.remote_addr, request.user_agent)
38-
visits = fetch_visits(10) or () # empty sequence if None
38+
visits = fetch_visits(10)
3939
return render_template('index.html', visits=visits)
4040

4141
if __name__ == '__main__':

step4-cloudndb-cloudrun-py2/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def fetch_visits(limit):
3434
@app.route('/')
3535
def root():
3636
store_visit(request.remote_addr, request.user_agent)
37-
visits = fetch_visits(10) or () # empty sequence if None
37+
visits = fetch_visits(10)
3838
return render_template('index.html', visits=visits)
3939

4040
if __name__ == '__main__':

step4a-cloudrun-bldpks-py3/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def fetch_visits(limit):
3535
@app.route('/')
3636
def root():
3737
store_visit(request.remote_addr, request.user_agent)
38-
visits = fetch_visits(10) or () # empty sequence if None
38+
visits = fetch_visits(10)
3939
return render_template('index.html', visits=visits)
4040

4141
if __name__ == '__main__':

0 commit comments

Comments
 (0)