summaryrefslogtreecommitdiff
path: root/docs/narr/configuration.rst
diff options
context:
space:
mode:
authorMichael Merickel <github@m.merickel.org>2018-08-21 01:44:55 -0500
committerGitHub <noreply@github.com>2018-08-21 01:44:55 -0500
commit820a752645b460ea8009b07a75c752ab09c53dec (patch)
tree14616d81a7abedfe523c057e71ed7b2aca680754 /docs/narr/configuration.rst
parentdf8598a2658632f709a64e8076cce02ca49de8e6 (diff)
parent254710cb716dccfe536b20d077e3cb79be19c6b3 (diff)
downloadpyramid-820a752645b460ea8009b07a75c752ab09c53dec.tar.gz
pyramid-820a752645b460ea8009b07a75c752ab09c53dec.tar.bz2
pyramid-820a752645b460ea8009b07a75c752ab09c53dec.zip
Merge pull request #3330 from stevepiercy/docs-code-style
Docs code style
Diffstat (limited to 'docs/narr/configuration.rst')
-rw-r--r--docs/narr/configuration.rst66
1 files changed, 33 insertions, 33 deletions
diff --git a/docs/narr/configuration.rst b/docs/narr/configuration.rst
index bbf01240e..5477c4ff6 100644
--- a/docs/narr/configuration.rst
+++ b/docs/narr/configuration.rst
@@ -37,21 +37,21 @@ one after the next. Here's one of the simplest :app:`Pyramid` applications,
configured imperatively:
.. code-block:: python
- :linenos:
+ :linenos:
- from wsgiref.simple_server import make_server
- from pyramid.config import Configurator
- from pyramid.response import Response
+ from wsgiref.simple_server import make_server
+ from pyramid.config import Configurator
+ from pyramid.response import Response
- def hello_world(request):
- return Response('Hello world!')
+ def hello_world(request):
+ return Response('Hello world!')
- if __name__ == '__main__':
- with Configurator() as config:
- config.add_view(hello_world)
- app = config.make_wsgi_app()
- server = make_server('0.0.0.0', 8080, app)
- server.serve_forever()
+ if __name__ == '__main__':
+ with Configurator() as config:
+ config.add_view(hello_world)
+ app = config.make_wsgi_app()
+ server = make_server('0.0.0.0', 8080, app)
+ server.serve_forever()
We won't talk much about what this application does yet. Just note that the
configuration statements take place underneath the ``if __name__ ==
@@ -80,14 +80,14 @@ by the configuration. To avoid this, :app:`Pyramid` allows you to insert
to by the declaration itself. For example:
.. code-block:: python
- :linenos:
+ :linenos:
- from pyramid.response import Response
- from pyramid.view import view_config
+ from pyramid.response import Response
+ from pyramid.view import view_config
- @view_config(name='hello', request_method='GET')
- def hello(request):
- return Response('Hello')
+ @view_config(name='hello', request_method='GET')
+ def hello(request):
+ return Response('Hello')
The mere existence of configuration decoration doesn't cause any configuration
registration to be performed. Before it has any effect on the configuration of
@@ -104,23 +104,23 @@ invoked: scanning implies searching for configuration declarations in a package
and its subpackages. For example:
.. code-block:: python
- :linenos:
+ :linenos:
- from wsgiref.simple_server import make_server
- from pyramid.config import Configurator
- from pyramid.response import Response
- from pyramid.view import view_config
+ from wsgiref.simple_server import make_server
+ from pyramid.config import Configurator
+ from pyramid.response import Response
+ from pyramid.view import view_config
- @view_config()
- def hello(request):
- return Response('Hello')
+ @view_config()
+ def hello(request):
+ return Response('Hello')
- if __name__ == '__main__':
- with Configurator() as config:
- config.scan()
- app = config.make_wsgi_app()
- server = make_server('0.0.0.0', 8080, app)
- server.serve_forever()
+ if __name__ == '__main__':
+ with Configurator() as config:
+ config.scan()
+ app = config.make_wsgi_app()
+ server = make_server('0.0.0.0', 8080, app)
+ server.serve_forever()
The scanning machinery imports each module and subpackage in a package or
module recursively, looking for special attributes attached to objects defined
@@ -143,7 +143,7 @@ In the example above, the scanner translates the arguments to
.. code-block:: python
- config.add_view(hello)
+ config.add_view(hello)
Summary
-------