diff options
Diffstat (limited to 'docs/narr/configuration.rst')
| -rw-r--r-- | docs/narr/configuration.rst | 66 |
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 ------- |
