summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Piercy <web@stevepiercy.com>2016-04-16 04:17:36 -0700
committerSteve Piercy <web@stevepiercy.com>2016-04-16 04:17:36 -0700
commit8e6520bd91d9b873b5e367176b7c303d7cac429a (patch)
tree5e67e1454984c23e10d01a7f3da4ccab89efeb6f
parent4e34c51b1e7c1ffa836cef81ee7b31cfdbdf69df (diff)
downloadpyramid-8e6520bd91d9b873b5e367176b7c303d7cac429a.tar.gz
pyramid-8e6520bd91d9b873b5e367176b7c303d7cac429a.tar.bz2
pyramid-8e6520bd91d9b873b5e367176b7c303d7cac429a.zip
quick_tutorial cleanup
- cleanup ini.rst
-rw-r--r--docs/quick_tutorial/ini.rst92
1 files changed, 46 insertions, 46 deletions
diff --git a/docs/quick_tutorial/ini.rst b/docs/quick_tutorial/ini.rst
index 0aed304df..fba5ce29e 100644
--- a/docs/quick_tutorial/ini.rst
+++ b/docs/quick_tutorial/ini.rst
@@ -7,28 +7,30 @@
Use Pyramid's ``pserve`` command with a ``.ini`` configuration file for
simpler, better application running.
+
Background
==========
-Pyramid has a first-class concept of
-:ref:`configuration <configuration_narr>` distinct from code.
-This approach is optional, but its presence makes it distinct from
-other Python web frameworks. It taps into Python's ``setuptools``
-library, which establishes conventions for installing and providing
-"entry points" for Python projects. Pyramid uses an entry point to
-let a Pyramid application know where to find the WSGI app.
+Pyramid has a first-class concept of :ref:`configuration <configuration_narr>`
+distinct from code. This approach is optional, but its presence makes it
+distinct from other Python web frameworks. It taps into Python's ``setuptools``
+library, which establishes conventions for installing and providing "entry
+points" for Python projects. Pyramid uses an entry point to let a Pyramid
+application know where to find the WSGI app.
+
Objectives
==========
-- Modify our ``setup.py`` to have an entry point telling Pyramid the
- location of the WSGI app
+- Modify our ``setup.py`` to have an entry point telling Pyramid the location
+ of the WSGI app.
+
+- Create an application driven by an ``.ini`` file.
-- Create an application driven by a ``.ini`` file
+- Start the application with Pyramid's ``pserve`` command.
-- Startup the application with Pyramid's ``pserve`` command
+- Move code into the package's ``__init__.py``.
-- Move code into the package's ``__init__.py``
Steps
=====
@@ -39,14 +41,14 @@ Steps
$ cd ..; cp -r package ini; cd ini
-#. Our ``ini/setup.py`` needs a setuptools "entry point" in the
- ``setup()`` function:
+#. Our ``ini/setup.py`` needs a setuptools "entry point" in the ``setup()``
+ function:
.. literalinclude:: ini/setup.py
:linenos:
-#. We can now install our project, thus generating (or re-generating) an
- "egg" at ``ini/tutorial.egg-info``:
+#. We can now install our project, thus generating (or re-generating) an "egg"
+ at ``ini/tutorial.egg-info``:
.. code-block:: bash
@@ -58,8 +60,8 @@ Steps
:language: ini
:linenos:
-#. We can refactor our startup code from the previous step's ``app.py``
- into ``ini/tutorial/__init__.py``:
+#. We can refactor our startup code from the previous step's ``app.py`` into
+ ``ini/tutorial/__init__.py``:
.. literalinclude:: ini/tutorial/__init__.py
:linenos:
@@ -81,27 +83,26 @@ Steps
Analysis
========
-Our ``development.ini`` file is read by ``pserve`` and serves to
-bootstrap our application. Processing then proceeds as described in
-the Pyramid chapter on
+Our ``development.ini`` file is read by ``pserve`` and serves to bootstrap our
+application. Processing then proceeds as described in the Pyramid chapter on
:ref:`application startup <startup_chapter>`:
-- ``pserve`` looks for ``[app:main]`` and finds ``use = egg:tutorial``
+- ``pserve`` looks for ``[app:main]`` and finds ``use = egg:tutorial``.
-- The projects's ``setup.py`` has defined an "entry point" (lines 9-12)
- for the project "main" entry point of ``tutorial:main``
+- The projects's ``setup.py`` has defined an "entry point" (lines 9-12) for the
+ project's "main" entry point of ``tutorial:main``.
-- The ``tutorial`` package's ``__init__`` has a ``main`` function
+- The ``tutorial`` package's ``__init__`` has a ``main`` function.
-- This function is invoked, with the values from certain ``.ini``
- sections passed in
+- This function is invoked, with the values from certain ``.ini`` sections
+ passed in.
The ``.ini`` file is also used for two other functions:
-- *Configuring the WSGI server*. ``[server:main]`` wires up the choice of
- which WSGI *server* for your WSGI *application*. In this case, we are using
- ``wsgiref`` bundled in the Python library. It also wires up the *port
- number*: ``port = 6543`` tells ``wsgiref`` to listen on port 6543.
+- *Configuring the WSGI server*. ``[server:main]`` wires up the choice of which
+ WSGI *server* for your WSGI *application*. In this case, we are using
+ ``wsgiref`` bundled in the Python library. It also wires up the *port
+ number*: ``port = 6543`` tells ``wsgiref`` to listen on port 6543.
- *Configuring Python logging*. Pyramid uses Python standard logging, which
needs a number of configuration values. The ``.ini`` serves this function.
@@ -109,27 +110,27 @@ The ``.ini`` file is also used for two other functions:
request.
We moved our startup code from ``app.py`` to the package's
-``tutorial/__init__.py``. This isn't necessary,
-but it is a common style in Pyramid to take the WSGI app bootstrapping
-out of your module's code and put it in the package's ``__init__.py``.
+``tutorial/__init__.py``. This isn't necessary, but it is a common style in
+Pyramid to take the WSGI app bootstrapping out of your module's code and put it
+in the package's ``__init__.py``.
+
+The ``pserve`` application runner has a number of command-line arguments and
+options. We are using ``--reload`` which tells ``pserve`` to watch the
+filesystem for changes to relevant code (Python files, the INI file, etc.) and,
+when something changes, restart the application. Very handy during development.
-The ``pserve`` application runner has a number of command-line arguments
-and options. We are using ``--reload`` which tells ``pserve`` to watch
-the filesystem for changes to relevant code (Python files, the INI file,
-etc.) and, when something changes, restart the application. Very handy
-during development.
Extra Credit
============
-#. If you don't like configuration and/or ``.ini`` files,
- could you do this yourself in Python code?
+#. If you don't like configuration and/or ``.ini`` files, could you do this
+ yourself in Python code?
-#. Can we have multiple ``.ini`` configuration files for a project? Why
- might you want to do that?
+#. Can we have multiple ``.ini`` configuration files for a project? Why might
+ you want to do that?
-#. The entry point in ``setup.py`` didn't mention ``__init__.py`` when
- it declared ``tutorial:main`` function. Why not?
+#. The entry point in ``setup.py`` didn't mention ``__init__.py`` when it
+ declared ``tutorial:main`` function. Why not?
#. What is the purpose of ``**settings``? What does the ``**`` signify?
@@ -139,4 +140,3 @@ Extra Credit
:ref:`what_is_this_pserve_thing`,
:ref:`environment_chapter`,
:ref:`paste_chapter`
-