diff options
Diffstat (limited to 'docs/quick_tutorial')
| -rw-r--r-- | docs/quick_tutorial/authentication.rst | 4 | ||||
| -rw-r--r-- | docs/quick_tutorial/debugtoolbar.rst | 28 | ||||
| -rw-r--r-- | docs/quick_tutorial/debugtoolbar/tutorial/__init__.py | 2 | ||||
| -rw-r--r-- | docs/quick_tutorial/forms/tutorial/wikipage_addedit.pt | 4 | ||||
| -rw-r--r-- | docs/quick_tutorial/hello_world.rst | 8 | ||||
| -rw-r--r-- | docs/quick_tutorial/ini.rst | 16 | ||||
| -rw-r--r-- | docs/quick_tutorial/logging.rst | 2 | ||||
| -rw-r--r-- | docs/quick_tutorial/more_view_classes.rst | 11 | ||||
| -rw-r--r-- | docs/quick_tutorial/more_view_classes/tutorial/views.py | 4 | ||||
| -rw-r--r-- | docs/quick_tutorial/package.rst | 7 | ||||
| -rw-r--r-- | docs/quick_tutorial/requirements.rst | 21 | ||||
| -rw-r--r-- | docs/quick_tutorial/scaffolds.rst | 8 | ||||
| -rw-r--r-- | docs/quick_tutorial/templating/setup.py | 4 | ||||
| -rw-r--r-- | docs/quick_tutorial/tutorial_approach.rst | 6 | ||||
| -rw-r--r-- | docs/quick_tutorial/unit_testing.rst | 2 |
15 files changed, 75 insertions, 52 deletions
diff --git a/docs/quick_tutorial/authentication.rst b/docs/quick_tutorial/authentication.rst index 8380a75ed..4b4eb1ba3 100644 --- a/docs/quick_tutorial/authentication.rst +++ b/docs/quick_tutorial/authentication.rst @@ -130,5 +130,5 @@ Extra Credit onto each request? Use ``import pdb; pdb.set_trace()`` to answer this. -.. seealso:: :ref:`security_chapter`, - :ref:`AuthTktAuthenticationPolicy <authentication_module>` +.. seealso:: See also :ref:`security_chapter`, + :ref:`AuthTktAuthenticationPolicy <authentication_module>`. diff --git a/docs/quick_tutorial/debugtoolbar.rst b/docs/quick_tutorial/debugtoolbar.rst index d25588c49..1c540d8a2 100644 --- a/docs/quick_tutorial/debugtoolbar.rst +++ b/docs/quick_tutorial/debugtoolbar.rst @@ -39,7 +39,6 @@ Steps $ $VENV/bin/python setup.py develop $ $VENV/bin/easy_install pyramid_debugtoolbar - #. Our ``debugtoolbar/development.ini`` gets a configuration entry for ``pyramid.includes``: @@ -86,4 +85,29 @@ start to experience otherwise inexplicable client-side weirdness, you can shut it off by commenting out the ``pyramid_debugtoolbar`` line in ``pyramid.includes`` temporarily. -.. seealso:: See Also: :ref:`pyramid_debugtoolbar <toolbar:overview>` +.. seealso:: See also :ref:`pyramid_debugtoolbar <toolbar:overview>`. + +Extra Credit +============ + +# Why don't we add ``pyramid_debugtoolbar`` to the list of + ``install_requires`` dependencies in ``debugtoolbar/setup.py``? + +# Introduce a bug into your application: Change: + + .. code-block:: python + + def hello_world(request): + return Response('<body><h1>Hello World!</h1></body>') + + to: + + .. code-block:: python + + def hello_world(request): + return xResponse('<body><h1>Hello World!</h1></body>') + + Save, and visit http://localhost:6543/ again. Notice the nice + traceback display. On the lowest line, click the "screen" icon to the + right, and try typing the variable names ``request`` and ``Response``. + What else can you discover? diff --git a/docs/quick_tutorial/debugtoolbar/tutorial/__init__.py b/docs/quick_tutorial/debugtoolbar/tutorial/__init__.py index 0993b25be..d784292ee 100644 --- a/docs/quick_tutorial/debugtoolbar/tutorial/__init__.py +++ b/docs/quick_tutorial/debugtoolbar/tutorial/__init__.py @@ -3,7 +3,7 @@ from pyramid.response import Response def hello_world(request): - return xResponse('<body><h1>Hello World!</h1></body>') + return Response('<body><h1>Hello World!</h1></body>') def main(global_config, **settings): diff --git a/docs/quick_tutorial/forms/tutorial/wikipage_addedit.pt b/docs/quick_tutorial/forms/tutorial/wikipage_addedit.pt index d1fea0d7f..3292dfd90 100644 --- a/docs/quick_tutorial/forms/tutorial/wikipage_addedit.pt +++ b/docs/quick_tutorial/forms/tutorial/wikipage_addedit.pt @@ -4,10 +4,10 @@ <title>WikiPage: Add/Edit</title> <tal:block tal:repeat="reqt view.reqts['css']"> <link rel="stylesheet" type="text/css" - href="${request.static_url('deform:static/' + reqt)}"/> + href="${request.static_url(reqt)}"/> </tal:block> <tal:block tal:repeat="reqt view.reqts['js']"> - <script src="${request.static_url('deform:static/' + reqt)}" + <script src="${request.static_url(reqt)}" type="text/javascript"></script> </tal:block> </head> diff --git a/docs/quick_tutorial/hello_world.rst b/docs/quick_tutorial/hello_world.rst index c7a8eaf5e..86e1319f0 100644 --- a/docs/quick_tutorial/hello_world.rst +++ b/docs/quick_tutorial/hello_world.rst @@ -71,11 +71,11 @@ New to Python web programming? If so, some lines in module merit explanation: #. *Line 11*. The ``if __name__ == '__main__':`` is Python's way of - saying "Start here when running from the command line". + saying "Start here when running from the command line", rather than + when this module is imported. #. *Lines 12-14*. Use Pyramid's :term:`configurator` to connect - :term:`view` code to a particular URL - :term:`route`. + :term:`view` code to a particular URL :term:`route`. #. *Lines 6-7*. Implement the view code that generates the :term:`response`. @@ -111,4 +111,4 @@ Extra Credit then reload your browser. See the exception in the console? #. The ``GI`` in ``WSGI`` stands for "Gateway Interface". What web - standard is this modelled after?
\ No newline at end of file + standard is this modelled after? diff --git a/docs/quick_tutorial/ini.rst b/docs/quick_tutorial/ini.rst index 618b8e5e8..3402c50e8 100644 --- a/docs/quick_tutorial/ini.rst +++ b/docs/quick_tutorial/ini.rst @@ -98,18 +98,16 @@ the Pyramid chapter on The ``.ini`` file is also used for two other functions: -- *Choice of WSGI server*. ``[server:main]`` wires up the choice of WSGI - *server* for your WSGI *application*. In this case, we are using - ``wsgiref`` bundled in the Python library. +- *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. -- *Python logging*. Pyramid uses Python standard logging, which needs a - number of configuration values. The ``.ini`` serves this function. +- *Configuring Python logging*. Pyramid uses Python standard logging, which + needs a number of configuration values. The ``.ini`` serves this function. This provides the console log output that you see on startup and each request. -- *Port number*. ``port = 6543`` tells ``wsgiref`` to listen on port - 6543. - 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 @@ -131,7 +129,7 @@ Extra Credit might you want to do that? #. The entry point in ``setup.py`` didn't mention ``__init__.py`` when - it the ``main`` function. Why not? + it declared ``tutorial:main`` function. Why not? .. seealso:: :ref:`project_narr`, diff --git a/docs/quick_tutorial/logging.rst b/docs/quick_tutorial/logging.rst index 0167e5249..855ded59f 100644 --- a/docs/quick_tutorial/logging.rst +++ b/docs/quick_tutorial/logging.rst @@ -76,4 +76,4 @@ visit http://localhost:6543 your console will now show:: Also, if you have configured your Pyramid application to use the ``pyramid_debugtoolbar``, logging statements appear in one of its menus. -.. seealso:: See Also: :ref:`logging_chapter` +.. seealso:: See also :ref:`logging_chapter`. diff --git a/docs/quick_tutorial/more_view_classes.rst b/docs/quick_tutorial/more_view_classes.rst index 21b353b7c..1e5603554 100644 --- a/docs/quick_tutorial/more_view_classes.rst +++ b/docs/quick_tutorial/more_view_classes.rst @@ -18,11 +18,10 @@ or a Python class. In this last case, methods on the class can be decorated with ``@view_config`` to register the class methods with the :term:`configurator` as a view. -So far our views have been simple, free-standing functions. Many times +At first, our views were simple, free-standing functions. Many times your views are related: different ways to look at or work on the same data or a REST API that handles multiple operations. Grouping these -together as a -:ref:`view class <class_as_view>` makes sense: +together as a :ref:`view class <class_as_view>` makes sense: - Group views @@ -30,9 +29,9 @@ together as a - Share some state and helpers -Pyramid views have -:ref:`view predicates <view_configuration_parameters>` that -help determine which view is matched to a request. These predicates +Pyramid views have :ref:`view predicates <view_configuration_parameters>` +that determine which view is matched to a request, based on factors +such as the request method, the form parameters, etc. These predicates provide many axes of flexibility. The following shows a simple example with four operations operations: diff --git a/docs/quick_tutorial/more_view_classes/tutorial/views.py b/docs/quick_tutorial/more_view_classes/tutorial/views.py index fdba04ba8..635de0520 100644 --- a/docs/quick_tutorial/more_view_classes/tutorial/views.py +++ b/docs/quick_tutorial/more_view_classes/tutorial/views.py @@ -20,7 +20,6 @@ class TutorialViews: def home(self): return {'page_title': 'Home View'} - # Retrieving /howdy/first/last the first time @view_config(renderer='hello.pt') def hello(self): @@ -33,7 +32,8 @@ class TutorialViews: return {'page_title': 'Edit View', 'new_name': new_name} # Posting to /home via the "Delete" submit button - @view_config(request_param='form.delete', renderer='delete.pt') + @view_config(request_method='POST', request_param='form.delete', + renderer='delete.pt') def delete(self): print ('Deleted') return {'page_title': 'Delete View'} diff --git a/docs/quick_tutorial/package.rst b/docs/quick_tutorial/package.rst index 90d022b29..8fb052d5b 100644 --- a/docs/quick_tutorial/package.rst +++ b/docs/quick_tutorial/package.rst @@ -22,8 +22,7 @@ Explaining it all in this tutorial will induce madness. For this tutorial, this is all you need to know: -- We will have a directory for each tutorial step as a - setuptools *project* +- We will have a directory for each tutorial step as a setuptools *project* - This project will contain a ``setup.py`` which injects the features of the setuptool's project machinery into the directory @@ -97,8 +96,8 @@ In this step we have a Python package called ``tutorial``. We use the same name in each step of the tutorial, to avoid unnecessary re-typing. Above this ``tutorial`` directory we have the files that handle the -packaging of this, well, package. At the moment, all we need is a -bare-bones ``ini/setup.py``. +packaging of this project. At the moment, all we need is a +bare-bones ``setup.py``. Everything else is the same about our application. We simply made a Python package with a ``setup.py`` and installed it in development mode. diff --git a/docs/quick_tutorial/requirements.rst b/docs/quick_tutorial/requirements.rst index 234e4aa0d..72bb4a4f8 100644 --- a/docs/quick_tutorial/requirements.rst +++ b/docs/quick_tutorial/requirements.rst @@ -226,25 +226,28 @@ during this tutorial: # Mac and Linux $ $VENV/bin/easy_install nose webtest deform sqlalchemy \ pyramid_chameleon pyramid_debugtoolbar waitress \ - pyramid_jinja2 pyramid_tm zope.sqlalchemy + pyramid_tm zope.sqlalchemy # Windows - c:\> %VENV%\Scripts\easy_install nose webtest deform sqlalchemy pyramid_chameleon - + c:\> %VENV%\Scripts\easy_install nose webtest deform sqlalchemy pyramid_chameleon pyramid_debugtoolbar waitress pyramid_tm zope.sqlalchemy .. note:: Why ``easy_install`` and not ``pip``? Pyramid encourages use of namespace - packages which, until recently, ``pip`` didn't permit. Also, Pyramid has - some optional C extensions for performance. With ``easy_install``, Windows - users can get these extensions without needing a C compiler. - -.. seealso:: See Also: :ref:`installing_unix`. For instructions to set up your + packages, for which ``pip``'s support is less-than-optimal. Also, Pyramid's + dependencies use some optional C extensions for performance: with + ``easy_install``, Windows users can get these extensions without needing + a C compiler (``pip`` does not support installing binary Windows + distributions, except for ``wheels``, which are not yet available for + all dependencies). + +.. seealso:: See also :ref:`installing_unix`. For instructions to set up your Python environment for development using Windows or Python 2, see Pyramid's :ref:`Before You Install <installing_chapter>`. - See also Python 3's :mod:`venv module <python3:venv>`, the `setuptools` `installation instructions + See also Python 3's :mod:`venv module <python3:venv>`, the `setuptools + installation instructions <https://pypi.python.org/pypi/setuptools/0.9.8#installation-instructions>`_, and `easy_install help <https://pypi.python.org/pypi/setuptools/0.9.8#using-setuptools-and-easyinstall>`_. diff --git a/docs/quick_tutorial/scaffolds.rst b/docs/quick_tutorial/scaffolds.rst index 8ca2d27df..4f2694100 100644 --- a/docs/quick_tutorial/scaffolds.rst +++ b/docs/quick_tutorial/scaffolds.rst @@ -63,11 +63,11 @@ Steps On startup, ``pserve`` logs some output: - .. code-block:: bash + .. code-block:: bash - Starting subprocess with file monitor - Starting server in PID 72213. - Starting HTTP server on http://0.0.0.0:6543 + Starting subprocess with file monitor + Starting server in PID 72213. + Starting HTTP server on http://0.0.0.0:6543 #. Open http://localhost:6543/ in your browser. diff --git a/docs/quick_tutorial/templating/setup.py b/docs/quick_tutorial/templating/setup.py index 2221b72e9..0b71b73e6 100644 --- a/docs/quick_tutorial/templating/setup.py +++ b/docs/quick_tutorial/templating/setup.py @@ -2,7 +2,7 @@ from setuptools import setup requires = [ 'pyramid', - 'pyramid_chameleon' + 'pyramid_chameleon', ] setup(name='tutorial', @@ -11,4 +11,4 @@ setup(name='tutorial', [paste.app_factory] main = tutorial:main """, -)
\ No newline at end of file +) diff --git a/docs/quick_tutorial/tutorial_approach.rst b/docs/quick_tutorial/tutorial_approach.rst index 52d768306..204d388b0 100644 --- a/docs/quick_tutorial/tutorial_approach.rst +++ b/docs/quick_tutorial/tutorial_approach.rst @@ -4,9 +4,9 @@ Tutorial Approach This tutorial uses conventions to keep the introduction focused and concise. Details, references, and deeper discussions are mentioned in -"See Also" notes. +"See also" notes. -.. seealso:: This is an example "See Also" note. +.. seealso:: This is an example "See also" note. This "Getting Started" tutorial is broken into independent steps, starting with the smallest possible "single file WSGI app" example. @@ -42,4 +42,4 @@ Each of the first-level directories (e.g. ``request_response``) is a *Python project* (except, as noted, the ``hello_world`` step.) The ``tutorial`` directory is a *Python package*. At the end of each step, we copy a previous directory into a new directory to use as a starting -point.
\ No newline at end of file +point. diff --git a/docs/quick_tutorial/unit_testing.rst b/docs/quick_tutorial/unit_testing.rst index ed33f62d7..f8a33b39d 100644 --- a/docs/quick_tutorial/unit_testing.rst +++ b/docs/quick_tutorial/unit_testing.rst @@ -116,4 +116,4 @@ Extra Credit #. Why do we import the ``hello_world`` view function *inside* the ``test_hello_world`` method instead of at the top of the module? -.. seealso:: See Also: :ref:`testing_chapter` +.. seealso:: See also :ref:`testing_chapter` |
