diff options
| author | Michael Merickel <michael@merickel.org> | 2017-07-12 20:06:48 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-07-12 20:06:48 -0500 |
| commit | d45f41f7423ef9064b827ef4d4d72bd41fd875f9 (patch) | |
| tree | b348ca6562eb1c80ea1baacdc0481ee6e95731b7 /docs/quick_tutorial | |
| parent | b8658e94f00962a78e3f8a4c97dd4fbc9e440a31 (diff) | |
| parent | 0958d268b4b5451c615e05b2b4657d2afb5a7cd4 (diff) | |
| download | pyramid-d45f41f7423ef9064b827ef4d4d72bd41fd875f9.tar.gz pyramid-d45f41f7423ef9064b827ef4d4d72bd41fd875f9.tar.bz2 pyramid-d45f41f7423ef9064b827ef4d4d72bd41fd875f9.zip | |
Merge pull request #3119 from stevepiercy/docs-context-manager
Update docs to use a Configurator context manager
Diffstat (limited to 'docs/quick_tutorial')
| -rw-r--r-- | docs/quick_tutorial/hello_world.rst | 2 | ||||
| -rw-r--r-- | docs/quick_tutorial/hello_world/app.py | 8 | ||||
| -rw-r--r-- | docs/quick_tutorial/package/tutorial/app.py | 12 |
3 files changed, 11 insertions, 11 deletions
diff --git a/docs/quick_tutorial/hello_world.rst b/docs/quick_tutorial/hello_world.rst index 2f2515fcd..94242f1f4 100644 --- a/docs/quick_tutorial/hello_world.rst +++ b/docs/quick_tutorial/hello_world.rst @@ -75,7 +75,7 @@ explanation: "Start here when running from the command line", rather than when this module is imported. -#. *Lines 12-14*. Use Pyramid's :term:`configurator` to connect :term:`view` +#. *Lines 12-14*. Use Pyramid's :term:`configurator` in a :term:`context manager` to connect :term:`view` code to a particular URL :term:`route`. #. *Lines 6-8*. Implement the view code that generates the :term:`response`. diff --git a/docs/quick_tutorial/hello_world/app.py b/docs/quick_tutorial/hello_world/app.py index 0a95f9ad3..d0351e251 100644 --- a/docs/quick_tutorial/hello_world/app.py +++ b/docs/quick_tutorial/hello_world/app.py @@ -9,9 +9,9 @@ def hello_world(request): if __name__ == '__main__': - config = Configurator() - config.add_route('hello', '/') - config.add_view(hello_world, route_name='hello') - app = config.make_wsgi_app() + with Configurator() as config: + config.add_route('hello', '/') + config.add_view(hello_world, route_name='hello') + app = config.make_wsgi_app() server = make_server('0.0.0.0', 6543, app) server.serve_forever() diff --git a/docs/quick_tutorial/package/tutorial/app.py b/docs/quick_tutorial/package/tutorial/app.py index 210075023..d0351e251 100644 --- a/docs/quick_tutorial/package/tutorial/app.py +++ b/docs/quick_tutorial/package/tutorial/app.py @@ -4,14 +4,14 @@ from pyramid.response import Response def hello_world(request): - print ('Incoming request') + print('Incoming request') return Response('<body><h1>Hello World!</h1></body>') if __name__ == '__main__': - config = Configurator() - config.add_route('hello', '/') - config.add_view(hello_world, route_name='hello') - app = config.make_wsgi_app() + with Configurator() as config: + config.add_route('hello', '/') + config.add_view(hello_world, route_name='hello') + app = config.make_wsgi_app() server = make_server('0.0.0.0', 6543, app) - server.serve_forever()
\ No newline at end of file + server.serve_forever() |
