summaryrefslogtreecommitdiff
path: root/docs/narr/configuration.rst
diff options
context:
space:
mode:
authorSteve Piercy <web@stevepiercy.com>2018-08-18 03:18:59 -0700
committerSteve Piercy <web@stevepiercy.com>2018-08-18 03:18:59 -0700
commit5a9458c46e2304be1b64398bffa370d12016125f (patch)
tree9db80fa6edf81569e6e9d5ce08055cd8810f8581 /docs/narr/configuration.rst
parent8a6ea258ce252883ddaef6dafbecd966cf058204 (diff)
downloadpyramid-5a9458c46e2304be1b64398bffa370d12016125f.tar.gz
pyramid-5a9458c46e2304be1b64398bffa370d12016125f.tar.bz2
pyramid-5a9458c46e2304be1b64398bffa370d12016125f.zip
Clean up code-blocks in configuration
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
-------