Skip to content

Commit

Permalink
Update example
Browse files Browse the repository at this point in the history
  • Loading branch information
rudyryk committed May 2, 2016
1 parent 0c47ebe commit fc910c1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
10 changes: 5 additions & 5 deletions docs/peewee_async/tornado.rst
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,16 @@ The complete working example is provided below. And here are some general notes:
})
async def get_or_create(self):
obj_id = self.get_argument('id', None)
async with self.application.objects.atomic():
obj, created = await self.application.objects.get_or_create(
TestNameModel, id=100,
defaults={'name': "TestNameModel id=100"})
TestNameModel, id=obj_id,
defaults={'name': "TestNameModel id=%s" % obj_id})
return obj
app.add_handlers('', [
(r"/", RootHandler),
(r"/create/", CreateHandler),
(r"/create", CreateHandler),
])
# Setup verbose logging
Expand All @@ -123,8 +124,7 @@ The complete working example is provided below. And here are some general notes:
Try GET urls:
http://127.0.0.1:8888?id=1
http://127.0.0.1:8888?id=2
http://127.0.0.1:8888?id=3
http://127.0.0.1:8888/create?id=100
Try POST with name=<some text> data:
http://127.0.0.1:8888
Expand Down
10 changes: 5 additions & 5 deletions examples/tornado_sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,16 @@ async def get(self):
})

async def get_or_create(self):
obj_id = self.get_argument('id', None)
async with self.application.objects.atomic():
obj, created = await self.application.objects.get_or_create(
TestNameModel, id=100,
defaults={'name': "TestNameModel id=100"})
TestNameModel, id=obj_id,
defaults={'name': "TestNameModel id=%s" % obj_id})
return obj

app.add_handlers('', [
(r"/", RootHandler),
(r"/create/", CreateHandler),
(r"/create", CreateHandler),
])

# Setup verbose logging
Expand All @@ -112,8 +113,7 @@ async def get_or_create(self):
Try GET urls:
http://127.0.0.1:8888?id=1
http://127.0.0.1:8888?id=2
http://127.0.0.1:8888?id=3
http://127.0.0.1:8888/create?id=100
Try POST with name=<some text> data:
http://127.0.0.1:8888
Expand Down

0 comments on commit fc910c1

Please sign in to comment.