From b0b28ede912c817a62a84b97c332e39eda02d166 Mon Sep 17 00:00:00 2001 From: Tshepang Lekhonkhobe Date: Mon, 16 Sep 2013 02:14:53 +0200 Subject: s/env/venv just for sake of consistency --- docs/quick_tour.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'docs/quick_tour.rst') diff --git a/docs/quick_tour.rst b/docs/quick_tour.rst index 4b23f7858..2303e9a5c 100644 --- a/docs/quick_tour.rst +++ b/docs/quick_tour.rst @@ -25,9 +25,9 @@ area in place. For Python 3.3: .. code-block:: bash - $ pyvenv-3.3 env33 - $ source env33/bin/activate - $ wget https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py -O - | python + $ pyvenv-3.3 venv + $ source venv/bin/activate + (venv)$ wget https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py -O - | python If ``wget`` complains with a certificate error, run it with: @@ -37,7 +37,7 @@ If ``wget`` complains with a certificate error, run it with: In these steps above we first made a :term:`virtualenv` and then "activated" it, which adjusted our path to look first in -``env33/bin`` for commands (such as ``python``). We next downloaded +``venv/bin`` for commands (such as ``python``). We next downloaded Python's packaging support and installed it, giving us the ``easy_install`` command-line script for adding new packages. Python 2.7 users will need to use ``virtualenv`` instead of ``pyvenv`` to make -- cgit v1.2.3 From 9b7f4d11b6beb3c60a2b11a280bc9c18ab01ad34 Mon Sep 17 00:00:00 2001 From: Steve Piercy Date: Tue, 24 Sep 2013 04:35:57 -0700 Subject: Update Requirements section --- docs/quick_tour.rst | 255 +++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 212 insertions(+), 43 deletions(-) (limited to 'docs/quick_tour.rst') diff --git a/docs/quick_tour.rst b/docs/quick_tour.rst index 2303e9a5c..ca2b0f826 100644 --- a/docs/quick_tour.rst +++ b/docs/quick_tour.rst @@ -4,73 +4,242 @@ Quick Tour of Pyramid ===================== -Pyramid lets you start small and finish big. This *Quick Tour* guide -walks you through many of Pyramid's key features. Let's put the -emphasis on *start* by doing a quick tour through Pyramid, with -snippets of code to illustrate major concepts. +Pyramid lets you start small and finish big. This *Quick Tour* of Pyramid is +for those who want to evaluate Pyramid and are not yet familiar with it. + + +Conventions +=========== +This guide uses conventions to keep the introduction focused and concise. +Details, references, and deeper discussions are mentioned in "See Also" +notes. + +.. seealso:: This is an example "See Also" note. + +Pyramid encourages standard Python development practices with packaging tools, +virtual environments, logging, and so on. There are many variations, +implementations, and opinions across the Python community, each of which may +have its proper usage. For the sake of consistency, ease of documentation +maintenance, and to minimize confusion, the Pyramid documentation has adopted +specific conventions: + +* Pyramid fully supports Python 3.2 or greater as well as Python 2.6 and 2.7. + This guide uses Python 3. +* We use ``pyvenv`` for isolating Python environments. +* We use ``setuptools`` for package management. +* We organize our file system where our home directory contains all of our + projects, which contains our workspaces, which contain both Python virtual + environments and projects. +* Commands in this guide use UNIX syntax and paths. Windows users should + adjust commands accordingly. .. note:: - We use Python 3 in our samples. Pyramid was one of the first - (October 2011) web frameworks to fully support Python 3. You can - use Python 3 as well for this guide, but you can also use Python 2.7. + Pyramid was one of the first web frameworks to fully support Python 3 in + October 2011. -Python Setup +Requirements ============ -First thing's first: we need our Python environment in ship-shape. -Pyramid encourages standard Python development practices (virtual -environments, packaging tools, logging, etc.) so let's get our working -area in place. For Python 3.3: +* :ref:`install-python-3.2-or-greater` +* :ref:`create-a-project-directory-structure` +* :ref:`set-an-environment-variable` +* :ref:`create-a-virtual-environment` +* :ref:`install-setuptools-(python-packaging-tools)` +* :ref:`install-pyramid` + +.. warning:: The current state of isolated Python environments using + ``pyvenv`` on Windows is suboptimal in comparison to Mac and Linux. See + http://stackoverflow.com/q/15981111/95735 for a discussion of the issue. + When it is resolved, or if any Windows user would like to step forward, + we would gratefully accept a pull request to update our documentation. + + Until then, we recommend that Windows users follow the procedure + :ref:`Installing Pyramid on a Windows System ` + +.. _install-python-3.2-or-greater: + +Install Python 3.2 or greater +----------------------------- + +Download the latest standard Python 3 release (not development release) from +`python.org `_. On that page, you +must click the latest version, then scroll down to the "Downloads" section +for your operating system. + +Windows and Mac OS X users can download and run an installer. + +Windows users should also install the `Python for Windows extensions +`_. Carefully read the +``README.txt`` file at the end of the list of builds, and follow its +directions. Make sure you get the proper 32- or 64-bit build and Python +version. + +Linux users can either use their package manager to install Python 3 or may +`build Python 3 from source +`_. + + +.. _create-a-project-directory-structure: + +Create a project directory structure +------------------------------------ + +From your user home directory, create the following initial directory structure +as indicated in the figure below. + +.. figure:: _static/directory_structure_initial.png + :alt: initial directory structure + + An initial directory structure. + +The commands to do so are as follows: + +.. code-block:: bash + + # Mac and Linux + $ cd ~ + $ mkdir projects + $ cd projects + $ mkdir pyramid + + # Windows + c:\> cd \ + c:\> mkdir projects + c:\> cd projects + c:\> mkdir pyramid + +In the above figure, your user home directory is represented by ``~``. In +your home directory, all of your projects are in the ``projects`` directory. +This is a general convention not specific to Pyramid that many developers use. +Windows users will do well to use ``c:\`` as the location for ``projects`` in +order to avoid spaces in any of the path names. + +Next within ``projects`` is your workspace directory, here named ``pyramid``. +A workspace is a common term used by integrated development environments (IDE) +like PyCharm and PyDev that stores isolated Python environments (virtualenvs) +and specific project files and repositories. + + +.. _set-an-environment-variable: + +Set an Environment Variable +--------------------------- + +We set an environment variable to save typing later. .. code-block:: bash + + # Mac and Linux + $ export VENV=~/projects/pyramid/env33/bin/ + + # Windows + # TODO: This command does not work + c:\> set VENV=c:\projects\pyramid\env33 - $ pyvenv-3.3 venv - $ source venv/bin/activate - (venv)$ wget https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py -O - | python -If ``wget`` complains with a certificate error, run it with: +.. _create-a-virtual-environment: + +Create a Virtual Environment +---------------------------- +``pyvenv`` is a tool to create isolated Python environments. Create one. .. code-block:: bash - $ wget --no-check-certificate + # Mac and Linux + $ pyvenv $VENV + + # Windows + # TODO: This command does work, but we should improve it with %VENV% + c:\> .\Python33\python -m venv c:\projects\pyramid\env33 -In these steps above we first made a :term:`virtualenv` and then -"activated" it, which adjusted our path to look first in -``venv/bin`` for commands (such as ``python``). We next downloaded -Python's packaging support and installed it, giving us the -``easy_install`` command-line script for adding new packages. Python -2.7 users will need to use ``virtualenv`` instead of ``pyvenv`` to make -their virtual environment. +.. note:: ``pyvenv`` is a tool to create isolated Python environments. The + venv module provides support for creating lightweight "virtual + environments" with their own site directories, optionally isolated from + system site directories. Each virtual environment has its own Python binary + (allowing creation of environments with various Python versions) and can + have its own independent set of installed Python packages in its site + directories. -.. note:: +.. seealso:: See also Python 3's :mod:`venv module ` and Python + 2's `virtualenv `_ package. - 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: Python 3's :mod:`venv module `, - the ``setuptools`` `installation - instructions `_, - `easy_install help `_, - and Pyramid's :ref:`Before You Install `. +.. _install-setuptools-(python-packaging-tools): -Pyramid Installation -==================== +Install ``setuptools`` (Python packaging tools) +----------------------------------------------- -We now have a standard starting point for Python. Getting Pyramid -installed is easy: +The following command will download a script to install ``setuptools``, then +pipe it to your environment's version of Python. .. code-block:: bash - $ easy_install pyramid + # Mac and Linux + $ wget https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py -O - | $VENV/python + + # Windows + # TODO Something goes here + +If ``wget`` complains with a certificate error, then run this command instead: + +.. code-block:: bash + + # Mac and Linux + $ wget --no-check-certificate https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py -O - | $VENV/python + + # Windows + # TODO Something goes here + + +.. _install-pyramid: + +Install Pyramid +--------------- + +.. code-block:: bash + + # Mac and Linux + $ easy_install pyramid + + # Windows + # TODO Something goes here + +Our Python environment now has the Pyramid software available. Your directory structure should now look like the following image. + +.. figure:: _static/directory_structure_pyramid.png + :alt: Pyramid directory structure + + A Pyramid directory structure. + + +.. 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 + Python environment for development using Windows or Python 2, see Pyramid's + :ref:`Before You Install `. + + See also Python 3's :mod:`venv module `, the `setuptools` `installation instructions + `_, + and `easy_install help `_. + +.. note:: A generic representation of project directory structure is shown in + the following figure. We could create multiple isolated Python + environments for multiple versions of Python. We could also add more + projects within our workspace directory, which is a common practice in the + Pyramid tutorials. + +.. figure:: _static/directory_structure_generic.png + :alt: generic directory structure -Our virtual environment now has the Pyramid software available to its -Python. + A generic directory structure. -.. seealso:: See Also: :ref:`installing_unix` Hello World =========== -- cgit v1.2.3 From 6a6d539409630343b7cf79f277eb0b3c402ee1ba Mon Sep 17 00:00:00 2001 From: Steve Piercy Date: Tue, 24 Sep 2013 05:03:37 -0700 Subject: Change python version to 3.3 --- docs/quick_tour.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'docs/quick_tour.rst') diff --git a/docs/quick_tour.rst b/docs/quick_tour.rst index ca2b0f826..e6bca0760 100644 --- a/docs/quick_tour.rst +++ b/docs/quick_tour.rst @@ -41,7 +41,7 @@ specific conventions: Requirements ============ -* :ref:`install-python-3.2-or-greater` +* :ref:`install-python-3.3-or-greater` * :ref:`create-a-project-directory-structure` * :ref:`set-an-environment-variable` * :ref:`create-a-virtual-environment` @@ -57,9 +57,9 @@ Requirements Until then, we recommend that Windows users follow the procedure :ref:`Installing Pyramid on a Windows System ` -.. _install-python-3.2-or-greater: +.. _install-python-3.3-or-greater: -Install Python 3.2 or greater +Install Python 3.3 or greater ----------------------------- Download the latest standard Python 3 release (not development release) from -- cgit v1.2.3 From 7801c187762357f6e36ce4cfe555038113af08fb Mon Sep 17 00:00:00 2001 From: Steve Piercy Date: Tue, 24 Sep 2013 05:13:02 -0700 Subject: add mention of PEP 453 --- docs/quick_tour.rst | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'docs/quick_tour.rst') diff --git a/docs/quick_tour.rst b/docs/quick_tour.rst index e6bca0760..c6cda54a6 100644 --- a/docs/quick_tour.rst +++ b/docs/quick_tour.rst @@ -50,9 +50,11 @@ Requirements .. warning:: The current state of isolated Python environments using ``pyvenv`` on Windows is suboptimal in comparison to Mac and Linux. See - http://stackoverflow.com/q/15981111/95735 for a discussion of the issue. - When it is resolved, or if any Windows user would like to step forward, - we would gratefully accept a pull request to update our documentation. + http://stackoverflow.com/q/15981111/95735 for a discussion of the issue + and `PEP 453 `_ for a proposed + resolution. When it is resolved, or if any Windows user would like to step + forward, we would gratefully accept a pull request to update our + documentation. Until then, we recommend that Windows users follow the procedure :ref:`Installing Pyramid on a Windows System ` -- cgit v1.2.3 From b731b5fca253d9d95b3307490aa585e194676c01 Mon Sep 17 00:00:00 2001 From: Paul Everitt Date: Thu, 26 Sep 2013 17:41:44 -0400 Subject: Quick Tour: shorten the setup part and point to Quick Tutorial Requirements for more explanation. Cross link each Quick Tour section with its Quick Tutorial match. --- docs/quick_tour.rst | 365 ++++++++++++++++------------------------------------ 1 file changed, 112 insertions(+), 253 deletions(-) (limited to 'docs/quick_tour.rst') diff --git a/docs/quick_tour.rst b/docs/quick_tour.rst index c6cda54a6..434dbdad5 100644 --- a/docs/quick_tour.rst +++ b/docs/quick_tour.rst @@ -5,216 +5,42 @@ Quick Tour of Pyramid ===================== Pyramid lets you start small and finish big. This *Quick Tour* of Pyramid is -for those who want to evaluate Pyramid and are not yet familiar with it. +for those who want to evaluate Pyramid, whether you are new to Python +web frameworks, or a pro in a hurry. For more detailed treatment of +each topic, give the :ref:`quick_tutorial` a try. - -Conventions -=========== -This guide uses conventions to keep the introduction focused and concise. -Details, references, and deeper discussions are mentioned in "See Also" -notes. - -.. seealso:: This is an example "See Also" note. - -Pyramid encourages standard Python development practices with packaging tools, -virtual environments, logging, and so on. There are many variations, -implementations, and opinions across the Python community, each of which may -have its proper usage. For the sake of consistency, ease of documentation -maintenance, and to minimize confusion, the Pyramid documentation has adopted -specific conventions: - -* Pyramid fully supports Python 3.2 or greater as well as Python 2.6 and 2.7. - This guide uses Python 3. -* We use ``pyvenv`` for isolating Python environments. -* We use ``setuptools`` for package management. -* We organize our file system where our home directory contains all of our - projects, which contains our workspaces, which contain both Python virtual - environments and projects. -* Commands in this guide use UNIX syntax and paths. Windows users should - adjust commands accordingly. - -.. note:: - - Pyramid was one of the first web frameworks to fully support Python 3 in - October 2011. - -Requirements +Installation ============ -* :ref:`install-python-3.3-or-greater` -* :ref:`create-a-project-directory-structure` -* :ref:`set-an-environment-variable` -* :ref:`create-a-virtual-environment` -* :ref:`install-setuptools-(python-packaging-tools)` -* :ref:`install-pyramid` - -.. warning:: The current state of isolated Python environments using - ``pyvenv`` on Windows is suboptimal in comparison to Mac and Linux. See - http://stackoverflow.com/q/15981111/95735 for a discussion of the issue - and `PEP 453 `_ for a proposed - resolution. When it is resolved, or if any Windows user would like to step - forward, we would gratefully accept a pull request to update our - documentation. - - Until then, we recommend that Windows users follow the procedure - :ref:`Installing Pyramid on a Windows System ` - -.. _install-python-3.3-or-greater: - -Install Python 3.3 or greater ------------------------------ - -Download the latest standard Python 3 release (not development release) from -`python.org `_. On that page, you -must click the latest version, then scroll down to the "Downloads" section -for your operating system. - -Windows and Mac OS X users can download and run an installer. - -Windows users should also install the `Python for Windows extensions -`_. Carefully read the -``README.txt`` file at the end of the list of builds, and follow its -directions. Make sure you get the proper 32- or 64-bit build and Python -version. - -Linux users can either use their package manager to install Python 3 or may -`build Python 3 from source -`_. - - -.. _create-a-project-directory-structure: - -Create a project directory structure ------------------------------------- - -From your user home directory, create the following initial directory structure -as indicated in the figure below. - -.. figure:: _static/directory_structure_initial.png - :alt: initial directory structure - - An initial directory structure. - -The commands to do so are as follows: - -.. code-block:: bash - - # Mac and Linux - $ cd ~ - $ mkdir projects - $ cd projects - $ mkdir pyramid - - # Windows - c:\> cd \ - c:\> mkdir projects - c:\> cd projects - c:\> mkdir pyramid - -In the above figure, your user home directory is represented by ``~``. In -your home directory, all of your projects are in the ``projects`` directory. -This is a general convention not specific to Pyramid that many developers use. -Windows users will do well to use ``c:\`` as the location for ``projects`` in -order to avoid spaces in any of the path names. - -Next within ``projects`` is your workspace directory, here named ``pyramid``. -A workspace is a common term used by integrated development environments (IDE) -like PyCharm and PyDev that stores isolated Python environments (virtualenvs) -and specific project files and repositories. - - -.. _set-an-environment-variable: - -Set an Environment Variable ---------------------------- - -We set an environment variable to save typing later. - -.. code-block:: bash - - # Mac and Linux - $ export VENV=~/projects/pyramid/env33/bin/ - - # Windows - # TODO: This command does not work - c:\> set VENV=c:\projects\pyramid\env33 - - -.. _create-a-virtual-environment: - -Create a Virtual Environment ----------------------------- -``pyvenv`` is a tool to create isolated Python environments. Create one. - -.. code-block:: bash - - # Mac and Linux - $ pyvenv $VENV - - # Windows - # TODO: This command does work, but we should improve it with %VENV% - c:\> .\Python33\python -m venv c:\projects\pyramid\env33 - -.. note:: ``pyvenv`` is a tool to create isolated Python environments. The - venv module provides support for creating lightweight "virtual - environments" with their own site directories, optionally isolated from - system site directories. Each virtual environment has its own Python binary - (allowing creation of environments with various Python versions) and can - have its own independent set of installed Python packages in its site - directories. - -.. seealso:: See also Python 3's :mod:`venv module ` and Python - 2's `virtualenv `_ package. - - -.. _install-setuptools-(python-packaging-tools): - -Install ``setuptools`` (Python packaging tools) ------------------------------------------------ +Once you have a standard Python environment setup, getting started with +Pyramid is a breeze. Unfortunately "standard" is not so simple in Python. +For this Quick Tour, it means: +`Python `_, a +`virtual environment `_ +(or `virtualenv for Python 2.7 `_, +and `setuptools `_. -The following command will download a script to install ``setuptools``, then -pipe it to your environment's version of Python. +As an example, for Python 3.3+ on Linux: .. code-block:: bash - # Mac and Linux - $ wget https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py -O - | $VENV/python - - # Windows - # TODO Something goes here + $ pyvenv env33 + $ wget https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py -O - | env33/bin/python + $ env33/bin/easy_install pyramid -If ``wget`` complains with a certificate error, then run this command instead: +For Windows: -.. code-block:: bash - - # Mac and Linux - $ wget --no-check-certificate https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py -O - | $VENV/python - - # Windows - # TODO Something goes here - - -.. _install-pyramid: - -Install Pyramid ---------------- - -.. code-block:: bash - - # Mac and Linux - $ easy_install pyramid - - # Windows - # TODO Something goes here - -Our Python environment now has the Pyramid software available. Your directory structure should now look like the following image. +.. code-block:: posh -.. figure:: _static/directory_structure_pyramid.png - :alt: Pyramid directory structure - - A Pyramid directory structure. + # Use your browser to download: + # https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py + c:\> c:\Python33\python -m venv env33 + c:\> env33\Scripts\python ez_setup.py + c:\> env33\Scripts\easy_install pyramid +Of course Pyramid runs fine on Python 2.6+, as do the examples in this +*Quick Tour*. We're just showing Python 3 a little love (Pyramid had +production support in October 2011.) .. note:: @@ -223,25 +49,11 @@ Our Python environment now has the Pyramid software available. Your directory s 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 - Python environment for development using Windows or Python 2, see Pyramid's - :ref:`Before You Install `. - - See also Python 3's :mod:`venv module `, the `setuptools` `installation instructions - `_, - and `easy_install help `_. - -.. note:: A generic representation of project directory structure is shown in - the following figure. We could create multiple isolated Python - environments for multiple versions of Python. We could also add more - projects within our workspace directory, which is a common practice in the - Pyramid tutorials. - -.. figure:: _static/directory_structure_generic.png - :alt: generic directory structure - - A generic directory structure. - +.. seealso:: See Also: + :ref:`Quick Tutorial section on Requirements `, + :ref:`installing_unix`, + :ref:`Before You Install `, and + :ref:`Installing Pyramid on a Windows System ` Hello World =========== @@ -280,7 +92,9 @@ in Pyramid development. Building an application from loosely-coupled parts via :doc:`../narr/configuration` is a central idea in Pyramid, one that we will revisit regurlarly in this *Quick Tour*. -.. seealso:: See Also: :ref:`firstapp_chapter` and +.. seealso:: See Also: + :ref:`Quick Tutorial Hello World `, + :ref:`firstapp_chapter`, and :ref:`Single File Tasks tutorial ` Handling Web Requests and Responses @@ -311,7 +125,10 @@ the name is included in the body of the response:: Finally, we set the response's content type and return the Response. -.. seealso:: See Also: :ref:`webob_chapter` +.. seealso:: See Also: + :ref:`Quick Tutorial Request and Response ` + and + :ref:`webob_chapter` Views ===== @@ -361,7 +178,9 @@ configuration`, in which a Python :term:`decorator` is placed on the line above the view. Both approaches result in the same final configuration, thus usually, it is simply a matter of taste. -.. seealso:: See Also: :doc:`../narr/views`, +.. seealso:: See Also: + :ref:`Quick Tutorial Views `, + :doc:`../narr/views`, :doc:`../narr/viewconfig`, and :ref:`debugging_view_configuration` @@ -407,7 +226,9 @@ view: "replacement patterns" (the curly braces) in the route declaration. This information can then be used in your view. -.. seealso:: See Also: :doc:`../narr/urldispatch`, +.. seealso:: See Also: + :ref:`Quick Tutorial Routing `, + :doc:`../narr/urldispatch`, :ref:`debug_routematch_section`, and :doc:`../narr/router` @@ -441,9 +262,11 @@ Since our view returned ``dict(name=request.matchdict['name'])``, we can use ``name`` as a variable in our template via ``${name}``. -.. seealso:: See Also: :doc:`../narr/templates`, - :ref:`debugging_templates`, and - :ref:`available_template_system_bindings` +.. seealso:: See Also: + :ref:`Quick Tutorial Templating `, + :doc:`../narr/templates`, + :ref:`debugging_templates`, and + :ref:`available_template_system_bindings` Templating With ``jinja2`` ========================== @@ -482,9 +305,10 @@ filename extensions. In this case, changing the extension from ``.pt`` to ``.jinja2`` passed the view response through the ``pyramid_jinja2`` renderer. -.. seealso:: See Also: `Jinja2 homepage `_, - and - :ref:`pyramid_jinja2 Overview ` +.. seealso:: See Also: + :ref:`Quick Tutorial Jinja2 `, + `Jinja2 homepage `_, and + :ref:`pyramid_jinja2 Overview ` Static Assets ============= @@ -529,9 +353,11 @@ By using ``request.static_url`` to generate the full URL to the static assets, you both ensure you stay in sync with the configuration and gain refactoring flexibility later. -.. seealso:: See Also: :doc:`../narr/assets`, - :ref:`preventing_http_caching`, and - :ref:`influencing_http_caching` +.. seealso:: See Also: + :ref:`Quick Tutorial Static Assets `, + :doc:`../narr/assets`, + :ref:`preventing_http_caching`, and + :ref:`influencing_http_caching` Returning JSON ============== @@ -548,9 +374,11 @@ This wires up a view that returns some data through the JSON :term:`renderer`, which calls Python's JSON support to serialize the data into JSON and set the appropriate HTTP headers. -.. seealso:: See Also: :ref:`views_which_use_a_renderer`, - :ref:`json_renderer`, and - :ref:`adding_and_overriding_renderers` +.. seealso:: See Also: + :ref:`Quick Tutorial JSON `, + :ref:`views_which_use_a_renderer`, + :ref:`json_renderer`, and + :ref:`adding_and_overriding_renderers` View Classes ============ @@ -593,7 +421,20 @@ Only one route needed, stated in one place atop the view class. Also, the assignment of the ``name`` is done in the ``__init__``. Our templates can then use ``{{ view.name }}``. -.. seealso:: See Also: :ref:`class_as_view` +Pyramid view classes, combined with built-in and custom predicates, +have much more to offer: + +- All the same view configuration parameters as function views + +- One route leading to multiple views, based on information in the + request or data such as ``request_param``, ``request_method``, + ``accept``, ``header``, ``xhr``, ``containment``, and + ``custom_predicates`` + +.. seealso:: See Also: + :ref:`Quick Tutorial View Classes `, + :ref:`Quick Tutorial More View Classes `, and + :ref:`class_as_view` Quick Project Startup with Scaffolds ==================================== @@ -641,8 +482,10 @@ configuration. This includes a new way of running your application: Let's look at ``pserve`` and configuration in more depth. -.. seealso:: See Also: :ref:`project_narr` and - :doc:`../narr/scaffolding` +.. seealso:: See Also: + :ref:`Quick Tutorial Scaffolds `, + :ref:`project_narr`, and + :doc:`../narr/scaffolding` Application Running with ``pserve`` =================================== @@ -670,7 +513,8 @@ Most of the work, though, comes from your project's wiring, as expressed in the configuration file you supply to ``pserve``. Let's take a look at this configuration file. -.. seealso:: See Also: :ref:`what_is_this_pserve_thing` +.. seealso:: See Also: + :ref:`what_is_this_pserve_thing` Configuration with ``.ini`` Files ================================= @@ -717,8 +561,10 @@ Additionally, the ``development.ini`` generated by this scaffold wired up Python's standard logging. We'll now see in the console, for example, a log on every request that comes in, as well traceback information. -.. seealso:: See Also: :ref:`environment_chapter` and - :doc:`../narr/paste` +.. seealso:: See Also: + :ref:`Quick Tutorial Application Configuration `, + :ref:`environment_chapter` and + :doc:`../narr/paste` Easier Development with ``debugtoolbar`` @@ -770,7 +616,10 @@ you want to disable this toolbar, no need to change code: you can remove it from ``pyramid.includes`` in the relevant ``.ini`` configuration file. -.. seealso:: See Also: :ref:`pyramid_debugtoolbar ` +.. seealso:: See Also: + :ref:`Quick Tutorial + pyramid_debugtoolbar ` and + :ref:`pyramid_debugtoolbar ` Unit Tests and ``nose`` ======================= @@ -821,7 +670,11 @@ Pyramid supplies helpers for test writing, which we use in the test setup and teardown. Our one test imports the view, makes a dummy request, and sees if the view returns what we expected. -.. seealso:: See Also: :ref:`testing_chapter` +.. seealso:: See Also: + :ref:`Quick Tutorial Unit Testing `, + :ref:`Quick Tutorial Functional Testing `, + and + :ref:`testing_chapter` Logging ======= @@ -864,7 +717,9 @@ visit ``http://localhost:6543`` your console will now show:: 2013-08-09 10:42:42,968 DEBUG [hello_world.views][MainThread] Some Message -.. seealso:: See Also: :ref:`logging_chapter` +.. seealso:: See Also: + :ref:`Quick Tutorial Logging ` and + :ref:`logging_chapter` Sessions ======== @@ -911,9 +766,10 @@ Jinja2 template: :end-before: End Sphinx Include 1 .. seealso:: See Also: - :ref:`sessions_chapter`, :ref:`flash_messages`, - :ref:`session_module`, and - :ref:`Beaker sessioning middleware ` + :ref:`Quick Tutorial Sessions `, + :ref:`sessions_chapter`, :ref:`flash_messages`, + :ref:`session_module`, and + :ref:`Beaker sessioning middleware ` Databases ========= @@ -958,10 +814,12 @@ of the system, can then easily get at the data thanks to SQLAlchemy: :start-after: Start Sphinx Include :end-before: End Sphinx Include -.. seealso:: See Also: `SQLAlchemy `_, - :ref:`making_a_console_script`, - :ref:`bfg_sql_wiki_tutorial`, and - :ref:`Application Transactions With pyramid_tm ` +.. seealso:: See Also: + :ref:`Quick Tutorial Databases `, + `SQLAlchemy `_, + :ref:`making_a_console_script`, + :ref:`bfg_sql_wiki_tutorial`, and + :ref:`Application Transactions With pyramid_tm ` Forms ===== @@ -1020,9 +878,10 @@ widgets using attractive CSS from Bootstrap and more powerful widgets from Chosen. .. seealso:: See Also: - :ref:`Deform `, - :ref:`Colander `, and - `deform_bootstrap `_ + :ref:`Quick Tutorial Forms `, + :ref:`Deform `, + :ref:`Colander `, and + `deform_bootstrap `_ Conclusion ========== -- cgit v1.2.3 From a8cb0406c3096486dd66204aa144cb117dab0890 Mon Sep 17 00:00:00 2001 From: Marius Gedminas Date: Sat, 28 Sep 2013 09:59:09 +0300 Subject: OCD: add back missing ) --- docs/quick_tour.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'docs/quick_tour.rst') diff --git a/docs/quick_tour.rst b/docs/quick_tour.rst index 434dbdad5..1ac5181f3 100644 --- a/docs/quick_tour.rst +++ b/docs/quick_tour.rst @@ -17,7 +17,7 @@ Pyramid is a breeze. Unfortunately "standard" is not so simple in Python. For this Quick Tour, it means: `Python `_, a `virtual environment `_ -(or `virtualenv for Python 2.7 `_, +(or `virtualenv for Python 2.7 `_), and `setuptools `_. As an example, for Python 3.3+ on Linux: -- cgit v1.2.3 From ebca905c2a2e1e796f3840baaf154a6d9d695cc4 Mon Sep 17 00:00:00 2001 From: Paul Everitt Date: Sat, 28 Sep 2013 12:14:13 -0400 Subject: Used a parsed-literal to pin the version number on easy_install. --- docs/quick_tour.rst | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'docs/quick_tour.rst') diff --git a/docs/quick_tour.rst b/docs/quick_tour.rst index 1ac5181f3..98584e608 100644 --- a/docs/quick_tour.rst +++ b/docs/quick_tour.rst @@ -22,21 +22,21 @@ and `setuptools `_. As an example, for Python 3.3+ on Linux: -.. code-block:: bash +.. parsed-literal:: $ pyvenv env33 $ wget https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py -O - | env33/bin/python - $ env33/bin/easy_install pyramid + $ env33/bin/easy_install "pyramid==\ |release|\ " For Windows: -.. code-block:: posh +.. parsed-literal:: # Use your browser to download: # https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py - c:\> c:\Python33\python -m venv env33 - c:\> env33\Scripts\python ez_setup.py - c:\> env33\Scripts\easy_install pyramid + c:\\> c:\\Python33\\python -m venv env33 + c:\\> env33\\Scripts\\python ez_setup.py + c:\\> env33\\Scripts\\easy_install "pyramid==\ |release|\ " Of course Pyramid runs fine on Python 2.6+, as do the examples in this *Quick Tour*. We're just showing Python 3 a little love (Pyramid had @@ -297,7 +297,7 @@ The only change in our view...point the renderer at the ``.jinja2`` file: Our Jinja2 template is very similar to our previous template: .. literalinclude:: quick_tour/jinja2/hello_world.jinja2 - :language: jinja + :language: html Pyramid's templating add-ons register a new kind of renderer into your application. The renderer registration maps to different kinds of -- cgit v1.2.3