Skip to content

Commit

Permalink
Update example apps to use config context manager in Quick Tour
Browse files Browse the repository at this point in the history
- add missing EOF line ending
  • Loading branch information
stevepiercy committed Jul 4, 2017
1 parent b6937e3 commit e33212c
Show file tree
Hide file tree
Showing 11 changed files with 60 additions and 60 deletions.
8 changes: 4 additions & 4 deletions docs/quick_tour/hello_world/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,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()
10 changes: 5 additions & 5 deletions docs/quick_tour/jinja2/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
from pyramid.config import Configurator

if __name__ == '__main__':
config = Configurator()
config.add_route('hello', '/howdy/{name}')
config.include('pyramid_jinja2')
config.scan('views')
app = config.make_wsgi_app()
with Configurator() as config:
config.add_route('hello', '/howdy/{name}')
config.include('pyramid_jinja2')
config.scan('views')
app = config.make_wsgi_app()
server = make_server('0.0.0.0', 6543, app)
server.serve_forever()
14 changes: 7 additions & 7 deletions docs/quick_tour/json/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
from pyramid.config import Configurator

if __name__ == '__main__':
config = Configurator()
config.add_route('hello', '/howdy/{name}')
config.add_route('hello_json', 'hello.json')
config.add_static_view(name='static', path='static')
config.include('pyramid_jinja2')
config.scan('views')
app = config.make_wsgi_app()
with Configurator() as config:
config.add_route('hello', '/howdy/{name}')
config.add_route('hello_json', 'hello.json')
config.add_static_view(name='static', path='static')
config.include('pyramid_jinja2')
config.scan('views')
app = config.make_wsgi_app()
server = make_server('0.0.0.0', 6543, app)
server.serve_forever()
8 changes: 4 additions & 4 deletions docs/quick_tour/requests/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,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()
10 changes: 5 additions & 5 deletions docs/quick_tour/routing/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
from pyramid.config import Configurator

if __name__ == '__main__':
config = Configurator()
config.add_route('hello', '/howdy/{first}/{last}')
config.scan('views')
app = config.make_wsgi_app()
with Configurator() as config:
config.add_route('hello', '/howdy/{first}/{last}')
config.scan('views')
app = config.make_wsgi_app()
server = make_server('0.0.0.0', 6543, app)
server.serve_forever()
server.serve_forever()
12 changes: 6 additions & 6 deletions docs/quick_tour/static_assets/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
from pyramid.config import Configurator

if __name__ == '__main__':
config = Configurator()
config.add_route('hello', '/howdy/{name}')
config.add_static_view(name='static', path='static')
config.include('pyramid_jinja2')
config.scan('views')
app = config.make_wsgi_app()
with Configurator() as config:
config.add_route('hello', '/howdy/{name}')
config.add_static_view(name='static', path='static')
config.include('pyramid_jinja2')
config.scan('views')
app = config.make_wsgi_app()
server = make_server('0.0.0.0', 6543, app)
server.serve_forever()
10 changes: 5 additions & 5 deletions docs/quick_tour/templating/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
from pyramid.config import Configurator

if __name__ == '__main__':
config = Configurator()
config.add_route('hello', '/howdy/{name}')
config.include('pyramid_chameleon')
config.scan('views')
app = config.make_wsgi_app()
with Configurator() as config:
config.add_route('hello', '/howdy/{name}')
config.include('pyramid_chameleon')
config.scan('views')
app = config.make_wsgi_app()
server = make_server('0.0.0.0', 6543, app)
server.serve_forever()
14 changes: 7 additions & 7 deletions docs/quick_tour/view_classes/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
from pyramid.config import Configurator

if __name__ == '__main__':
config = Configurator()
config.add_route('hello', '/howdy/{name}')
config.add_route('hello_json', 'hello.json')
config.add_static_view(name='static', path='static')
config.include('pyramid_jinja2')
config.scan('views')
app = config.make_wsgi_app()
with Configurator() as config:
config.add_route('hello', '/howdy/{name}')
config.add_route('hello_json', 'hello.json')
config.add_static_view(name='static', path='static')
config.include('pyramid_jinja2')
config.scan('views')
app = config.make_wsgi_app()
server = make_server('0.0.0.0', 6543, app)
server.serve_forever()
14 changes: 7 additions & 7 deletions docs/quick_tour/views/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
from pyramid.config import Configurator

if __name__ == '__main__':
config = Configurator()
config.add_route('home', '/')
config.add_route('hello', '/howdy')
config.add_route('redirect', '/goto')
config.add_route('exception', '/problem')
config.scan('views')
app = config.make_wsgi_app()
with Configurator() as config:
config.add_route('home', '/')
config.add_route('hello', '/howdy')
config.add_route('redirect', '/goto')
config.add_route('exception', '/problem')
config.scan('views')
app = config.make_wsgi_app()
server = make_server('0.0.0.0', 6543, app)
server.serve_forever()
8 changes: 4 additions & 4 deletions docs/quick_tutorial/hello_world/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
12 changes: 6 additions & 6 deletions docs/quick_tutorial/package/tutorial/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@


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()
server.serve_forever()

0 comments on commit e33212c

Please sign in to comment.