Skip to content

Commit fc910c1

Browse files
committed
Update example
1 parent 0c47ebe commit fc910c1

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

docs/peewee_async/tornado.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,15 +102,16 @@ The complete working example is provided below. And here are some general notes:
102102
})
103103
104104
async def get_or_create(self):
105+
obj_id = self.get_argument('id', None)
105106
async with self.application.objects.atomic():
106107
obj, created = await self.application.objects.get_or_create(
107-
TestNameModel, id=100,
108-
defaults={'name': "TestNameModel id=100"})
108+
TestNameModel, id=obj_id,
109+
defaults={'name': "TestNameModel id=%s" % obj_id})
109110
return obj
110111
111112
app.add_handlers('', [
112113
(r"/", RootHandler),
113-
(r"/create/", CreateHandler),
114+
(r"/create", CreateHandler),
114115
])
115116
116117
# Setup verbose logging
@@ -123,8 +124,7 @@ The complete working example is provided below. And here are some general notes:
123124
124125
Try GET urls:
125126
http://127.0.0.1:8888?id=1
126-
http://127.0.0.1:8888?id=2
127-
http://127.0.0.1:8888?id=3
127+
http://127.0.0.1:8888/create?id=100
128128
129129
Try POST with name=<some text> data:
130130
http://127.0.0.1:8888

examples/tornado_sample.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,15 +91,16 @@ async def get(self):
9191
})
9292

9393
async def get_or_create(self):
94+
obj_id = self.get_argument('id', None)
9495
async with self.application.objects.atomic():
9596
obj, created = await self.application.objects.get_or_create(
96-
TestNameModel, id=100,
97-
defaults={'name': "TestNameModel id=100"})
97+
TestNameModel, id=obj_id,
98+
defaults={'name': "TestNameModel id=%s" % obj_id})
9899
return obj
99100

100101
app.add_handlers('', [
101102
(r"/", RootHandler),
102-
(r"/create/", CreateHandler),
103+
(r"/create", CreateHandler),
103104
])
104105

105106
# Setup verbose logging
@@ -112,8 +113,7 @@ async def get_or_create(self):
112113
113114
Try GET urls:
114115
http://127.0.0.1:8888?id=1
115-
http://127.0.0.1:8888?id=2
116-
http://127.0.0.1:8888?id=3
116+
http://127.0.0.1:8888/create?id=100
117117
118118
Try POST with name=<some text> data:
119119
http://127.0.0.1:8888

0 commit comments

Comments
 (0)