From 499b78aea5bc94626a48022afcf8cf92afb55cf8 Mon Sep 17 00:00:00 2001 From: Donald Stufft Date: Sun, 23 Aug 2015 11:59:51 -0400 Subject: [PATCH 001/102] Add a RouteFound event which will fire after a route is found --- pyramid/events.py | 19 +++++++++++++++++++ pyramid/interfaces.py | 8 ++++++++ pyramid/router.py | 3 +++ 3 files changed, 30 insertions(+) diff --git a/pyramid/events.py b/pyramid/events.py index 97375638ee..78ebf4d703 100644 --- a/pyramid/events.py +++ b/pyramid/events.py @@ -11,6 +11,7 @@ INewResponse, IApplicationCreated, IBeforeRender, + IRouteFound, ) class subscriber(object): @@ -129,6 +130,24 @@ def __init__(self, request, response): self.request = request self.response = response +@implementer(IRouteFound) +class RouteFound(object): + """ + An instance of this class is emitted as an :term:`event` after the + :app:`Pyramid` :term:`router` finds a :term:`route` object but before any + traversal or view code is executed. The instance has an attribute, + ``request``, which is the request object generated by :app:`Pyramid`. + + Notably, the request object will have an attributed named + ``matched_route``, which is the matched route that was found. + + This class implements the :class:`pyramid.interfaces.IRouteFound` + interface. + """ + + def __init__(self, request): + self.request = request + @implementer(IContextFound) class ContextFound(object): """ An instance of this class is emitted as an :term:`event` after diff --git a/pyramid/interfaces.py b/pyramid/interfaces.py index 90534593c3..baf36610a6 100644 --- a/pyramid/interfaces.py +++ b/pyramid/interfaces.py @@ -25,6 +25,14 @@ class IContextFound(Interface): IAfterTraversal = IContextFound +class IRouteFound(Interface): + """ + An event type that is emitted whenever :app:`Pyramid` has found a route + but before it calls any traversal or view code. See the documentation + attached to :class:`pyramid.events.Routefound` for more information. + """ + request = Attribute('The request object') + class INewRequest(Interface): """ An event type that is emitted whenever :app:`Pyramid` begins to process a new request. See the documentation attached diff --git a/pyramid/router.py b/pyramid/router.py index 4054ef52ee..c4b86f89de 100644 --- a/pyramid/router.py +++ b/pyramid/router.py @@ -20,6 +20,7 @@ ContextFound, NewRequest, NewResponse, + RouteFound, ) from pyramid.httpexceptions import HTTPNotFound @@ -112,6 +113,8 @@ def handle_request(self, request): name=route.name, default=IRequest) + has_listeners and notify(RouteFound(request)) + root_factory = route.factory or self.root_factory root = root_factory(request) From a7dd0531b427d8633fc222830f24b737048e9c8a Mon Sep 17 00:00:00 2001 From: Steve Piercy Date: Wed, 30 Mar 2016 05:53:35 -0700 Subject: [PATCH 002/102] update installation and glossary --- docs/glossary.rst | 4 ++ docs/tutorials/wiki2/installation.rst | 76 ++++++++++++++++++++++----- 2 files changed, 67 insertions(+), 13 deletions(-) diff --git a/docs/glossary.rst b/docs/glossary.rst index 9657d92191..ef90a0f412 100644 --- a/docs/glossary.rst +++ b/docs/glossary.rst @@ -1091,3 +1091,7 @@ Glossary A technique used when serving a cacheable static asset in order to force a client to query the new version of the asset. See :ref:`cache_busting` for more information. + + pip + The `Python Packaging Authority `_ recommended tool + for installing Python packages. diff --git a/docs/tutorials/wiki2/installation.rst b/docs/tutorials/wiki2/installation.rst index 891305bf58..b263ccbd9e 100644 --- a/docs/tutorials/wiki2/installation.rst +++ b/docs/tutorials/wiki2/installation.rst @@ -9,9 +9,9 @@ This tutorial assumes that you have already followed the steps in :ref:`installing_chapter`, except **do not create a virtualenv or install Pyramid**. Thereby you will satisfy the following requirements. -* Python interpreter is installed on your operating system -* :term:`setuptools` or :term:`distribute` is installed -* :term:`virtualenv` is installed +* A Python interpreter is installed on your operating system. +* :term:`virtualenv` is installed. +* :term:`pip` will be installed when we create a virtual environment. Create directory to contain the project @@ -72,6 +72,24 @@ Python 3.5: c:\> c:\Python35\Scripts\virtualenv %VENV% +Upgrade pip in the virtual environment +-------------------------------------- + +On UNIX +^^^^^^^ + +.. code-block:: bash + + $ $VENV/bin/pip install --upgrade pip + +On Windows +^^^^^^^^^^ + +.. code-block:: ps1con + + c:\> %VENV%\Scripts\pip install --upgrade pip + + Install Pyramid into the virtual Python environment --------------------------------------------------- @@ -80,26 +98,27 @@ On UNIX .. code-block:: bash - $ $VENV/bin/easy_install pyramid + $ $VENV/bin/pip install pyramid On Windows ^^^^^^^^^^ .. code-block:: ps1con - c:\> %VENV%\Scripts\easy_install pyramid + c:\> %VENV%\Scripts\pip install pyramid Install SQLite3 and its development packages -------------------------------------------- -If you used a package manager to install your Python or if you compiled your -Python from source, then you must install SQLite3 and its development packages. -If you downloaded your Python as an installer from https://www.python.org, then -you already have it installed and can skip this step. +If you used a package manager to install your Python or if you compiled +your Python from source, then you must install SQLite3 and its +development packages. If you downloaded your Python as an installer +from https://www.python.org, then you already have it installed and can skip +this step. -If you need to install the SQLite3 packages, then, for example, using the -Debian system and ``apt-get``, the command would be the following: +If you need to install the SQLite3 packages, then, for example, using +the Debian system and ``apt-get``, the command would be the following: .. code-block:: bash @@ -168,6 +187,7 @@ On Windows and the project into directories that do not contain spaces in their paths. + .. _installing_project_in_dev_mode: Installing the project in development mode @@ -185,7 +205,7 @@ On UNIX .. code-block:: bash $ cd tutorial - $ $VENV/bin/python setup.py develop + $ $VENV/bin/pip install -e . On Windows ^^^^^^^^^^ @@ -193,7 +213,7 @@ On Windows .. code-block:: ps1con c:\pyramidtut> cd tutorial - c:\pyramidtut\tutorial> %VENV%\Scripts\python setup.py develop + c:\pyramidtut\tutorial> %VENV%\Scripts\pip install -e . The console will show ``setup.py`` checking for packages and installing missing packages. Success executing this command will show a line like the following:: @@ -215,6 +235,8 @@ On UNIX $ $VENV/bin/python setup.py test -q +.. py.test? See https://github.com/Pylons/pyramid/issues/2104#issuecomment-155852046 + On Windows ^^^^^^^^^^ @@ -222,6 +244,8 @@ On Windows c:\pyramidtut\tutorial> %VENV%\Scripts\python setup.py test -q +.. py.test? See https://github.com/Pylons/pyramid/issues/2104#issuecomment-155852046 + For a successful test run, you should see output that ends like this:: .. @@ -310,6 +334,13 @@ initialize our database. already have a database, you should delete it before running ``initialize_tutorial_db`` again. +.. note:: + + The ``initialize_tutorial_db`` command is not performing a migration but + rather simply creating missing tables and adding some dummy data. If you + already have a database, you should delete it before running + ``initialize_tutorial_db`` again. + Type the following command, making sure you are still in the ``tutorial`` directory (the directory with a ``development.ini`` in it): @@ -415,6 +446,13 @@ assumptions: - You are willing to use :term:`URL dispatch` to map URLs to code. +- You want to use zope.sqlalchemy_, pyramid_tm_ and the transaction_ package + to scope sessions to requests. + +- You want to use pyramid_jinja2_ to render your templates. + Different templating engines can be used but we had to choose one to + make the tutorial. See :ref:`available_template_system_bindings` for some + options. - You want to use zope.sqlalchemy_, pyramid_tm_ and the transaction_ package to scope sessions to requests. @@ -440,3 +478,15 @@ assumptions: .. _transaction: http://zodb.readthedocs.org/en/latest/transactions.html + +.. _pyramid_jinja2: + http://docs.pylonsproject.org/projects/pyramid-jinja2/en/latest/ + +.. _pyramid_tm: + http://docs.pylonsproject.org/projects/pyramid-tm/en/latest/ + +.. _zope.sqlalchemy: + https://pypi.python.org/pypi/zope.sqlalchemy + +.. _transaction: + http://zodb.readthedocs.org/en/latest/transactions.html From 5562586cd45b994325fce4893dc0f74580eccdea Mon Sep 17 00:00:00 2001 From: Steve Piercy Date: Thu, 31 Mar 2016 02:24:43 -0700 Subject: [PATCH 003/102] - update links to PyPA site as practical - update various easy_install/setup.py commands to use pip - update to use py35 - other small improvements --- docs/quick_tour.rst | 53 +++++++++++++++++++++------------------------ 1 file changed, 25 insertions(+), 28 deletions(-) diff --git a/docs/quick_tour.rst b/docs/quick_tour.rst index 65310bf4d1..3554fc7244 100644 --- a/docs/quick_tour.rst +++ b/docs/quick_tour.rst @@ -15,28 +15,29 @@ Installation 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 -`_. +Quick Tour, it means `Python `_, `venv +`_ (or `virtualenv for +Python 2.7 `_), +`pip `_, and `setuptools +`_. -As an example, for Python 3.3+ on Linux: +As an example, for Python 3.5+ on Linux: .. parsed-literal:: - $ pyvenv env33 - $ wget https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py -O - | env33/bin/python - $ env33/bin/easy_install "pyramid==\ |release|\ " + $ pyvenv env35 + $ env35/bin/pip install pyramid + # or for a specific released version + $ env35/bin/pip install "pyramid==\ |release|\ " For Windows: .. 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==\ |release|\ " + c:\\> c:\\Python35\\python -m venv env35 + c:\\> env35\\Scripts\\pip install pyramid + # or for a specific released version + c:\\> env35\\Scripts\\pip 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 production @@ -44,14 +45,8 @@ support for Python 3 in October 2011). .. note:: - Why ``easy_install`` and not ``pip``? Some distributions upon which - Pyramid depends have optional C extensions for performance. ``pip`` cannot - install some binary Python distributions. With ``easy_install``, Windows - users are able to obtain binary Python distributions, so they get the - benefit of the C extensions without needing a C compiler. Also there can - be issues when ``pip`` and ``easy_install`` are used side-by-side in the - same environment, so we chose to recommend ``easy_install`` for the sake of - reducing the complexity of these instructions. + If you use Python 2.6 or 2.7, then you might need to install + ``setuptools``. See references below for more information. .. seealso:: See also: :ref:`Quick Tutorial section on Requirements `, @@ -249,7 +244,7 @@ Chameleon as a :term:`renderer` in our Pyramid application: .. code-block:: bash - $ easy_install pyramid_chameleon + $ env35/bin/pip install pyramid_chameleon With the package installed, we can include the template bindings into our configuration in ``app.py``: @@ -293,7 +288,7 @@ Jinja2 as a :term:`renderer` in our Pyramid applications: .. code-block:: bash - $ easy_install pyramid_jinja2 + $ env35/bin/pip install pyramid_jinja2 With the package installed, we can include the template bindings into our configuration: @@ -502,7 +497,7 @@ We next use the normal Python command to set up our package for development: .. code-block:: bash $ cd hello_world - $ python ./setup.py develop + $ $VENV/bin/pip install -e . We are moving in the direction of a full-featured Pyramid project, with a proper setup for Python standards (packaging) and Pyramid configuration. This @@ -617,7 +612,7 @@ It was installed when you previously ran: .. code-block:: bash - $ python ./setup.py develop + $ $VENV/bin/pip install -e . The ``pyramid_debugtoolbar`` package is a Pyramid add-on, which means we need to include its configuration into our web application. The ``pyramid_jinja2`` @@ -670,7 +665,7 @@ following: }, We changed ``setup.py`` which means we need to rerun -``python ./setup.py develop``. We can now run all our tests: +``$VENV/bin/pip install -e .``. We can now run all our tests: .. code-block:: bash @@ -746,7 +741,9 @@ These emphasized sections in the configuration file: Our application, a package named ``hello_world``, is set up as a logger and configured to log messages at a ``DEBUG`` or higher level. When you visit -http://localhost:6543, your console will now show:: +http://localhost:6543, your console will now show: + +.. code-block:: text 2016-01-18 13:55:55,040 DEBUG [hello_world.views:10][waitress] Some Message @@ -827,7 +824,7 @@ Pyramid and SQLAlchemy are great friends. That friendship includes a scaffold! $ pcreate --scaffold alchemy sqla_demo $ cd sqla_demo - $ python setup.py develop + $ $VENV/bin/pip install -e . We now have a working sample SQLAlchemy application with all dependencies installed. The sample project provides a console script to initialize a SQLite From e4995d86ce6570dcfea440cafc92aecc40c421ad Mon Sep 17 00:00:00 2001 From: Steve Piercy Date: Thu, 31 Mar 2016 02:28:14 -0700 Subject: [PATCH 004/102] - change env35 to just env. --- docs/quick_tour.rst | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/docs/quick_tour.rst b/docs/quick_tour.rst index 3554fc7244..0673952180 100644 --- a/docs/quick_tour.rst +++ b/docs/quick_tour.rst @@ -25,19 +25,19 @@ As an example, for Python 3.5+ on Linux: .. parsed-literal:: - $ pyvenv env35 - $ env35/bin/pip install pyramid + $ pyvenv env + $ env/bin/pip install pyramid # or for a specific released version - $ env35/bin/pip install "pyramid==\ |release|\ " + $ env/bin/pip install "pyramid==\ |release|\ " For Windows: .. parsed-literal:: - c:\\> c:\\Python35\\python -m venv env35 - c:\\> env35\\Scripts\\pip install pyramid + c:\\> c:\\Python35\\python -m venv env + c:\\> env\\Scripts\\pip install pyramid # or for a specific released version - c:\\> env35\\Scripts\\pip install "pyramid==\ |release|\ " + c:\\> env\\Scripts\\pip 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 production @@ -244,7 +244,7 @@ Chameleon as a :term:`renderer` in our Pyramid application: .. code-block:: bash - $ env35/bin/pip install pyramid_chameleon + $ env/bin/pip install pyramid_chameleon With the package installed, we can include the template bindings into our configuration in ``app.py``: @@ -288,7 +288,7 @@ Jinja2 as a :term:`renderer` in our Pyramid applications: .. code-block:: bash - $ env35/bin/pip install pyramid_jinja2 + $ env/bin/pip install pyramid_jinja2 With the package installed, we can include the template bindings into our configuration: From 7725b8ca96ae63f0767145aa192e3d5a67da4a1b Mon Sep 17 00:00:00 2001 From: Steve Piercy Date: Thu, 31 Mar 2016 02:29:40 -0700 Subject: [PATCH 005/102] - change $VENV to just env. --- docs/quick_tour.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/quick_tour.rst b/docs/quick_tour.rst index 0673952180..32f049d6ae 100644 --- a/docs/quick_tour.rst +++ b/docs/quick_tour.rst @@ -497,7 +497,7 @@ We next use the normal Python command to set up our package for development: .. code-block:: bash $ cd hello_world - $ $VENV/bin/pip install -e . + $ env/bin/pip install -e . We are moving in the direction of a full-featured Pyramid project, with a proper setup for Python standards (packaging) and Pyramid configuration. This @@ -612,7 +612,7 @@ It was installed when you previously ran: .. code-block:: bash - $ $VENV/bin/pip install -e . + $ env/bin/pip install -e . The ``pyramid_debugtoolbar`` package is a Pyramid add-on, which means we need to include its configuration into our web application. The ``pyramid_jinja2`` @@ -665,7 +665,7 @@ following: }, We changed ``setup.py`` which means we need to rerun -``$VENV/bin/pip install -e .``. We can now run all our tests: +``env/bin/pip install -e .``. We can now run all our tests: .. code-block:: bash @@ -824,7 +824,7 @@ Pyramid and SQLAlchemy are great friends. That friendship includes a scaffold! $ pcreate --scaffold alchemy sqla_demo $ cd sqla_demo - $ $VENV/bin/pip install -e . + $ env/bin/pip install -e . We now have a working sample SQLAlchemy application with all dependencies installed. The sample project provides a console script to initialize a SQLite From f1eb47f14aea0e9a1dde39ed08a9bf6728614cbf Mon Sep 17 00:00:00 2001 From: Steve Piercy Date: Sat, 2 Apr 2016 02:05:22 -0700 Subject: [PATCH 006/102] remove note to install setuptools --- docs/quick_tour.rst | 5 ----- 1 file changed, 5 deletions(-) diff --git a/docs/quick_tour.rst b/docs/quick_tour.rst index 32f049d6ae..f1cec97e92 100644 --- a/docs/quick_tour.rst +++ b/docs/quick_tour.rst @@ -43,11 +43,6 @@ 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 for Python 3 in October 2011). -.. note:: - - If you use Python 2.6 or 2.7, then you might need to install - ``setuptools``. See references below for more information. - .. seealso:: See also: :ref:`Quick Tutorial section on Requirements `, :ref:`installing_unix`, :ref:`Before You Install `, and From 44bbbc32b607b043e708a625c4b1756db8919bdd Mon Sep 17 00:00:00 2001 From: Steve Piercy Date: Sun, 3 Apr 2016 02:17:59 -0700 Subject: [PATCH 007/102] - replace easy_install with pip - bump Python version to 3.5 or generalize to Python 3 - rewrite seealso's - use ps1con lexer for windows powershell console - add hyperlink targets --- docs/narr/install.rst | 6 ++ docs/quick_tutorial/requirements.rst | 118 ++++++++------------------- 2 files changed, 42 insertions(+), 82 deletions(-) diff --git a/docs/narr/install.rst b/docs/narr/install.rst index 767b16fc07..4a2f228a3d 100644 --- a/docs/narr/install.rst +++ b/docs/narr/install.rst @@ -29,6 +29,9 @@ Some :app:`Pyramid` dependencies may attempt to build C extensions for performance speedups. If a compiler or Python headers are unavailable the dependency will fall back to using pure Python instead. + +.. _for-mac-os-x-users: + For Mac OS X Users ~~~~~~~~~~~~~~~~~~ @@ -52,6 +55,9 @@ Alternatively, you can use the `homebrew `_ package manager. If you use an installer for your Python, then you can skip to the section :ref:`installing_unix`. + +.. _if-you-don-t-yet-have-a-python-interpreter-unix: + If You Don't Yet Have a Python Interpreter (UNIX) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/quick_tutorial/requirements.rst b/docs/quick_tutorial/requirements.rst index f855dcb55a..3373ba2bc2 100644 --- a/docs/quick_tutorial/requirements.rst +++ b/docs/quick_tutorial/requirements.rst @@ -4,9 +4,9 @@ Requirements ============ -Let's get our tutorial environment setup. Most of the setup work is in -standard Python development practices (install Python, -make an isolated environment, and setup packaging tools.) +Let's get our tutorial environment set up. Most of the set up work is in +standard Python development practices (install Python and make an isolated +environment.) .. note:: @@ -19,16 +19,14 @@ make an isolated environment, and setup packaging tools.) This *Quick Tutorial* is based on: -* **Python 3.3**. Pyramid fully supports Python 3.3+ and Python 2.6+. - This tutorial uses **Python 3.3** but runs fine under Python 2.7. +* **Python 3.5**. Pyramid fully supports Python 3.3+ and Python 2.6+. This + tutorial uses **Python 3.5** but runs fine under Python 2.7. -* **pyvenv**. We believe in virtual environments. For this tutorial, - we use Python 3.3's built-in solution, the ``pyvenv`` command. - For Python 2.7, you can install ``virtualenv``. +* **pyvenv**. We believe in virtual environments. For this tutorial, we use + Python 3.5's built-in solution, the ``pyvenv`` command. For Python 2.7, you + can install ``virtualenv``. -* **setuptools and easy_install**. We use - `setuptools `_ - and its ``easy_install`` for package management. +* **pip**. We use ``pip`` for package management. * **Workspaces, projects, and packages.** Our home directory will contain a *tutorial workspace* with our Python virtual @@ -46,34 +44,39 @@ This *Quick Tutorial* is based on: Steps ===== -#. :ref:`install-python-3.3-or-greater` +#. :ref:`install-python-3` #. :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` -.. _install-python-3.3-or-greater: -Install Python 3.3 or greater ------------------------------ +.. _install-python-3: -Download the latest standard Python 3.3+ release (not development release) -from `python.org `_. +Install Python 3 +---------------- Windows and Mac OS X users can download and run an installer. +Download the latest standard Python 3 release (not development release) from +`python.org `_. + 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.3 -or may `build Python 3.3 from source +Linux users can either use their package manager to install Python 3 +or may `build Python 3 from source `_. +.. seealso:: See also :ref:`For Mac OS X Users `, + :ref:`If You Don't Yet Have a Python Interpreter (UNIX) + `, and :ref:`Installing + Pyramid on a Windows System `. + .. _create-a-project-directory-structure: @@ -142,6 +145,8 @@ environment. We set an environment variable to save typing later. # Mac and Linux $ export VENV=~/projects/quick_tutorial/env +.. code-block:: ps1con + # Windows # TODO: This command does not work c:\> set VENV=c:\projects\quick_tutorial\env @@ -158,7 +163,7 @@ Create a Virtual Environment and `PEP 453 `_ for a proposed resolution. -``pyvenv`` is a tool to create isolated Python 3.3 environments, each +``pyvenv`` is a tool to create isolated Python 3 environments, each with its own Python binary and independent set of installed Python packages in its site directories. Let's create one, using the location we just specified in the environment variable. @@ -168,46 +173,13 @@ we just specified in the environment variable. # Mac and Linux $ pyvenv $VENV - # Windows - c:\> c:\Python33\python -m venv %VENV% - -.. seealso:: See also Python 3's :mod:`venv module `, - Python 2's `virtualenv `_ - package, - :ref:`Installing Pyramid on a Windows System ` - - -.. _install-setuptools-(python-packaging-tools): - -Install ``setuptools`` (Python packaging tools) ------------------------------------------------ - -The following command will download a script to install ``setuptools``, then -pipe it to your environment's version of Python. - -.. code-block:: bash - - # Mac and Linux - $ wget https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py -O - | $VENV/bin/python +.. code-block:: ps1con # Windows - # - # Use your web browser to download this file: - # https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py - # - # ...and save it to: - # c:\projects\quick_tutorial\ez_setup.py - # - # Then run the following command: - - c:\> %VENV%\Scripts\python ez_setup.py - -If ``wget`` complains with a certificate error, then run this command instead: + c:\> c:\Python35\python -m venv %VENV% -.. code-block:: bash - - # Mac and Linux - $ wget --no-check-certificate https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py -O - | $VENV/bin/python +.. seealso:: See also Python 3's :mod:`venv module ` and Python + 2's `virtualenv `_ package. .. _install-pyramid: @@ -221,10 +193,10 @@ part is pretty easy: .. parsed-literal:: # Mac and Linux - $ $VENV/bin/easy_install "pyramid==\ |release|\ " + $ $VENV/bin/pip install "pyramid==\ |release|\ " # Windows - c:\\> %VENV%\\Scripts\\easy_install "pyramid==\ |release|\ " + c:\\> %VENV%\\Scripts\\pip install "pyramid==\ |release|\ " Our Python virtual environment now has the Pyramid software available. @@ -234,30 +206,12 @@ during this tutorial: .. code-block:: bash # Mac and Linux - $ $VENV/bin/easy_install nose webtest deform sqlalchemy \ + $ $VENV/bin/pip install nose webtest deform sqlalchemy \ pyramid_chameleon pyramid_debugtoolbar waitress \ pyramid_tm zope.sqlalchemy - # Windows - c:\> %VENV%\Scripts\easy_install nose webtest deform sqlalchemy pyramid_chameleon pyramid_debugtoolbar waitress pyramid_tm zope.sqlalchemy - - -.. note:: +.. code-block:: ps1con - Why ``easy_install`` and not ``pip``? Pyramid encourages use of namespace - 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 `. - - See also Python 3's :mod:`venv module `, the `setuptools - installation instructions - `_, - and `easy_install help `_. + # Windows + c:\> %VENV%\Scripts\pip install nose webtest deform sqlalchemy pyramid_chameleon pyramid_debugtoolbar waitress pyramid_tm zope.sqlalchemy From 74c56e0e8d767ac0942cb17cde535113e97d8db1 Mon Sep 17 00:00:00 2001 From: Steve Piercy Date: Mon, 4 Apr 2016 00:43:27 -0700 Subject: [PATCH 008/102] - replace setup.py with pip --- docs/quick_tutorial/hello_world.rst | 2 +- docs/quick_tutorial/scaffolds.rst | 11 ++++++----- docs/quick_tutorial/tutorial_approach.rst | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/docs/quick_tutorial/hello_world.rst b/docs/quick_tutorial/hello_world.rst index 4ae80ca87f..fb661e9c5e 100644 --- a/docs/quick_tutorial/hello_world.rst +++ b/docs/quick_tutorial/hello_world.rst @@ -5,7 +5,7 @@ ================================ What's the simplest way to get started in Pyramid? A single-file module. -No Python packages, no ``setup.py``, no other machinery. +No Python packages, no ``pip install -e .``, no other machinery. Background ========== diff --git a/docs/quick_tutorial/scaffolds.rst b/docs/quick_tutorial/scaffolds.rst index 4f2694100a..319eb9d908 100644 --- a/docs/quick_tutorial/scaffolds.rst +++ b/docs/quick_tutorial/scaffolds.rst @@ -12,7 +12,7 @@ Background ========== We're going to cover a lot in this tutorial, focusing on one topic at a -time and writing everything from scratch. As a warmup, though, +time and writing everything from scratch. As a warm up, though, it sure would be nice to see some pixels on a screen. Like other web development frameworks, Pyramid provides a number of @@ -47,21 +47,22 @@ Steps $ $VENV/bin/pcreate --scaffold starter scaffolds -#. Use normal Python development to setup our project for development: +#. Install our project in editable mode for development in the current + directory: .. code-block:: bash $ cd scaffolds - $ $VENV/bin/python setup.py develop + $ $VENV/bin/pip install -e . -#. Startup the application by pointing Pyramid's ``pserve`` command at +#. Start up the application by pointing Pyramid's ``pserve`` command at the project's (generated) configuration file: .. code-block:: bash $ $VENV/bin/pserve development.ini --reload - On startup, ``pserve`` logs some output: + On start up, ``pserve`` logs some output: .. code-block:: bash diff --git a/docs/quick_tutorial/tutorial_approach.rst b/docs/quick_tutorial/tutorial_approach.rst index 204d388b04..8298a47100 100644 --- a/docs/quick_tutorial/tutorial_approach.rst +++ b/docs/quick_tutorial/tutorial_approach.rst @@ -17,7 +17,7 @@ repo, where each step/topic/directory is a Python package. To successfully run each step:: $ cd request_response - $ $VENV/bin/python setup.py develop + $ $VENV/bin/pip install -e . ...and repeat for each step you would like to work on. In most cases we will start with the results of an earlier step. From 7c29ea97c6617d1f6b2f621bf88aa6a0ab0209fa Mon Sep 17 00:00:00 2001 From: Steve Piercy Date: Tue, 5 Apr 2016 03:34:34 -0700 Subject: [PATCH 009/102] - replace easy_install with pip - add python3 for intersphinx. See #2429 - minor grammar --- docs/quick_tutorial/conf.py | 3 +++ docs/quick_tutorial/package.rst | 40 +++++++++++++++------------------ 2 files changed, 21 insertions(+), 22 deletions(-) diff --git a/docs/quick_tutorial/conf.py b/docs/quick_tutorial/conf.py index 47b8fae41b..feebdf02a8 100644 --- a/docs/quick_tutorial/conf.py +++ b/docs/quick_tutorial/conf.py @@ -257,6 +257,9 @@ 'python': ( 'http://docs.python.org/2', None), + 'python3': ( + 'https://docs.python.org/3/', + None), 'sqla': ( 'http://docs.sqlalchemy.org/en/latest', None), diff --git a/docs/quick_tutorial/package.rst b/docs/quick_tutorial/package.rst index 54a6a0bd9b..9e175bdaaf 100644 --- a/docs/quick_tutorial/package.rst +++ b/docs/quick_tutorial/package.rst @@ -10,43 +10,38 @@ Background ========== Python developers can organize a collection of modules and files into a -namespaced unit called a :ref:`package `. If a +namespaced unit called a :ref:`package `. If a directory is on ``sys.path`` and has a special file named ``__init__.py``, it is treated as a Python package. -Packages can be bundled up, made available for installation, -and installed through a (muddled, but improving) toolchain oriented -around a ``setup.py`` file for a -`setuptools project `_. -Explaining it all in this -tutorial will induce madness. For this tutorial, this is all you need to -know: +Packages can be bundled up, made available for installation, and installed +through a toolchain oriented around a ``setup.py`` file. 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 *project*. -- This project will contain a ``setup.py`` which injects the features - of the setuptool's project machinery into the directory +- This project will contain a ``setup.py`` which injects the features of the + project machinery into the directory. - In this project we will make a ``tutorial`` subdirectory into a Python - *package* using an ``__init__.py`` Python module file + *package* using an ``__init__.py`` Python module file. -- We will run ``python setup.py develop`` to install our project in - development mode +- We will run ``pip install -e .`` to install our project in development mode. In summary: -- You'll do your development in a Python *package* +- You'll do your development in a Python *package*. -- That package will be part of a setuptools *project* +- That package will be part of a *project*. Objectives ========== -- Make a Python "package" directory with an ``__init__.py`` +- Make a Python "package" directory with an ``__init__.py``. -- Get a minimum Python "project" in place by making a ``setup.py`` +- Get a minimum Python "project" in place by making a ``setup.py``. -- Install our ``tutorial`` project in development mode +- Install our ``tutorial`` project in development mode. Steps ===== @@ -66,7 +61,7 @@ Steps .. code-block:: bash - $ $VENV/bin/python setup.py develop + $ $VENV/bin/pip install -e . $ mkdir tutorial #. Enter the following into ``package/tutorial/__init__.py``: @@ -107,5 +102,6 @@ of an odd duck. We would never do this unless we were writing a tutorial that tries to capture how this stuff works a step at a time. It's generally a bad idea to run a Python module inside a package directly as a script. -.. seealso:: :ref:`Python Packages `, - `setuptools Entry Points `_ +.. seealso:: :ref:`Python Packages ` and `Working in + "Development Mode" + `_. From 186b72e56600c79888795fa4eed286a5ebf71974 Mon Sep 17 00:00:00 2001 From: Steve Piercy Date: Wed, 6 Apr 2016 04:24:28 -0700 Subject: [PATCH 010/102] - remove conf.py straggler - update intersphinx link to python3 docs - Closes #2429 --- docs/conf.py | 3 +- docs/quick_tutorial/conf.py | 284 --------------------------- docs/quick_tutorial/package.rst | 4 +- docs/quick_tutorial/requirements.rst | 2 +- 4 files changed, 4 insertions(+), 289 deletions(-) delete mode 100644 docs/quick_tutorial/conf.py diff --git a/docs/conf.py b/docs/conf.py index a895bc6c39..1600e1f5cb 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -66,8 +66,7 @@ def nothing(*arg): 'deform': ('http://docs.pylonsproject.org/projects/deform/en/latest', None), 'jinja2': ('http://docs.pylonsproject.org/projects/pyramid-jinja2/en/latest/', None), 'pylonswebframework': ('http://docs.pylonsproject.org/projects/pylons-webframework/en/latest/', None), - 'python': ('http://docs.python.org', None), - 'python3': ('http://docs.python.org/3', None), + 'python': ('https://docs.python.org/3', None), 'sqla': ('http://docs.sqlalchemy.org/en/latest', None), 'tm': ('http://docs.pylonsproject.org/projects/pyramid-tm/en/latest/', None), 'toolbar': ('http://docs.pylonsproject.org/projects/pyramid-debugtoolbar/en/latest', None), diff --git a/docs/quick_tutorial/conf.py b/docs/quick_tutorial/conf.py deleted file mode 100644 index feebdf02a8..0000000000 --- a/docs/quick_tutorial/conf.py +++ /dev/null @@ -1,284 +0,0 @@ -# -*- coding: utf-8 -*- -# -# Getting Started with Pyramid and REST documentation build configuration file, created by -# sphinx-quickstart on Mon Aug 26 14:44:57 2013. -# -# This file is execfile()d with the current directory set to its containing dir. -# -# Note that not all possible configuration values are present in this -# autogenerated file. -# -# All configuration values have a default; values that are commented out -# serve to show the default. - -import sys, os - -# If extensions (or modules to document with autodoc) are in another directory, -# add these directories to sys.path here. If the directory is relative to the -# documentation root, use os.path.abspath to make it absolute, like shown here. -#sys.path.insert(0, os.path.abspath('.')) - -# -- General configuration ----------------------------------------------------- - -# If your documentation needs a minimal Sphinx version, state it here. -#needs_sphinx = '1.0' - -# Add any Sphinx extension module names here, as strings. They can be extensions -# coming with Sphinx (named 'sphinx.ext.*') or your custom ones. -extensions = ['sphinx.ext.intersphinx'] - -# Add any paths that contain templates here, relative to this directory. -templates_path = ['_templates'] - -# The suffix of source filenames. -source_suffix = '.rst' - -# The encoding of source files. -#source_encoding = 'utf-8-sig' - -# The master toctree document. -master_doc = 'index' - -# General information about the project. -project = u'Getting Started with Pyramid and REST' -copyright = u'2013, Agendaless Consulting' - -# The version info for the project you're documenting, acts as replacement for -# |version| and |release|, also used in various other places throughout the -# built documents. -# -# The short X.Y version. -version = '1.0' -# The full version, including alpha/beta/rc tags. -release = '1.0' - -# The language for content autogenerated by Sphinx. Refer to documentation -# for a list of supported languages. -#language = None - -# There are two options for replacing |today|: either, you set today to some -# non-false value, then it is used: -#today = '' -# Else, today_fmt is used as the format for a strftime call. -#today_fmt = '%B %d, %Y' - -# List of patterns, relative to source directory, that match files and -# directories to ignore when looking for source files. -exclude_patterns = ['_build'] - -# The reST default role (used for this markup: `text`) to use for all documents. -#default_role = None - -# If true, '()' will be appended to :func: etc. cross-reference text. -#add_function_parentheses = True - -# If true, the current module name will be prepended to all description -# unit titles (such as .. function::). -#add_module_names = True - -# If true, sectionauthor and moduleauthor directives will be shown in the -# output. They are ignored by default. -#show_authors = False - -# The name of the Pygments (syntax highlighting) style to use. -pygments_style = 'sphinx' - -# A list of ignored prefixes for module index sorting. -#modindex_common_prefix = [] - -# If true, keep warnings as "system message" paragraphs in the built documents. -#keep_warnings = False - - -# -- Options for HTML output --------------------------------------------------- - -# The theme to use for HTML and HTML Help pages. See the documentation for -# a list of builtin themes. -html_theme = 'default' - -# Theme options are theme-specific and customize the look and feel of a theme -# further. For a list of options available for each theme, see the -# documentation. -#html_theme_options = {} - -# Add any paths that contain custom themes here, relative to this directory. -#html_theme_path = [] - -# The name for this set of Sphinx documents. If None, it defaults to -# " v documentation". -#html_title = None - -# A shorter title for the navigation bar. Default is the same as html_title. -#html_short_title = None - -# The name of an image file (relative to this directory) to place at the top -# of the sidebar. -#html_logo = None - -# The name of an image file (within the static path) to use as favicon of the -# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 -# pixels large. -#html_favicon = None - -# Add any paths that contain custom static files (such as style sheets) here, -# relative to this directory. They are copied after the builtin static files, -# so a file named "default.css" will overwrite the builtin "default.css". -html_static_path = ['_static'] - -# If not '', a 'Last updated on:' timestamp is inserted at every page bottom, -# using the given strftime format. -#html_last_updated_fmt = '%b %d, %Y' - -# If true, SmartyPants will be used to convert quotes and dashes to -# typographically correct entities. -#html_use_smartypants = True - -# Custom sidebar templates, maps document names to template names. -#html_sidebars = {} - -# Additional templates that should be rendered to pages, maps page names to -# template names. -#html_additional_pages = {} - -# If false, no module index is generated. -#html_domain_indices = True - -# If false, no index is generated. -#html_use_index = True - -# If true, the index is split into individual pages for each letter. -#html_split_index = False - -# If true, links to the reST sources are added to the pages. -#html_show_sourcelink = True - -# If true, "Created using Sphinx" is shown in the HTML footer. Default is True. -#html_show_sphinx = True - -# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. -#html_show_copyright = True - -# If true, an OpenSearch description file will be output, and all pages will -# contain a tag referring to it. The value of this option must be the -# base URL from which the finished HTML is served. -#html_use_opensearch = '' - -# This is the file name suffix for HTML files (e.g. ".xhtml"). -#html_file_suffix = None - -# Output file base name for HTML help builder. -htmlhelp_basename = 'GettingStartedwithPyramidandRESTdoc' - - -# -- Options for LaTeX output -------------------------------------------------- - -latex_elements = { - # The paper size ('letterpaper' or 'a4paper'). - #'papersize': 'letterpaper', - - # The font size ('10pt', '11pt' or '12pt'). - #'pointsize': '10pt', - - # Additional stuff for the LaTeX preamble. - #'preamble': '', -} - -# Grouping the document tree into LaTeX files. List of tuples -# (source start file, target name, title, author, documentclass [howto/manual]). -latex_documents = [ - ('index', 'GettingStartedwithPyramidandREST.tex', - u'Getting Started with Pyramid and REST Documentation', - u'Agendaless Consulting', 'manual'), -] - -# The name of an image file (relative to this directory) to place at the top of -# the title page. -#latex_logo = None - -# For "manual" documents, if this is true, then toplevel headings are parts, -# not chapters. -#latex_use_parts = False - -# If true, show page references after internal links. -#latex_show_pagerefs = False - -# If true, show URL addresses after external links. -#latex_show_urls = False - -# Documents to append as an appendix to all manuals. -#latex_appendices = [] - -# If false, no module index is generated. -#latex_domain_indices = True - - -# -- Options for manual page output -------------------------------------------- - -# One entry per manual page. List of tuples -# (source start file, name, description, authors, manual section). -man_pages = [ - ('index', 'gettingstartedwithpyramidandrest', - u'Getting Started with Pyramid and REST Documentation', - [u'Agendaless Consulting'], 1) -] - -# If true, show URL addresses after external links. -#man_show_urls = False - - -# -- Options for Texinfo output ------------------------------------------------ - -# Grouping the document tree into Texinfo files. List of tuples -# (source start file, target name, title, author, -# dir menu entry, description, category) -texinfo_documents = [ - ('index', 'GettingStartedwithPyramidandREST', - u'Getting Started with Pyramid and REST Documentation', - u'Agendaless Consulting', 'GettingStartedwithPyramidandREST', - 'One line description of project.', - 'Miscellaneous'), -] - -# Documents to append as an appendix to all manuals. -#texinfo_appendices = [] - -# If false, no module index is generated. -#texinfo_domain_indices = True - -# How to display URL addresses: 'footnote', 'no', or 'inline'. -#texinfo_show_urls = 'footnote' - -# If true, do not generate a @detailmenu in the "Top" node's menu. -#texinfo_no_detailmenu = False - - -# Example configuration for intersphinx: refer to the Python standard library. -intersphinx_mapping = { - 'python': ( - 'http://docs.python.org/2', - None), - 'python3': ( - 'https://docs.python.org/3/', - None), - 'sqla': ( - 'http://docs.sqlalchemy.org/en/latest', - None), - 'pyramid': ( - 'http://docs.pylonsproject.org/projects/pyramid/en/latest/', - None), - 'jinja2': ( - 'http://docs.pylonsproject.org/projects/pyramid_jinja2/en/latest/', - None), - 'toolbar': ( - 'http://docs.pylonsproject.org/projects/pyramid_debugtoolbar/en/latest', - None), - 'deform': ( - 'http://docs.pylonsproject.org/projects/deform/en/latest', - None), - 'colander': ( - 'http://docs.pylonsproject.org/projects/colander/en/latest', - None), - 'tutorials': ( - 'http://docs.pylonsproject.org/projects/pyramid_tutorials/en/latest/', - None), -} diff --git a/docs/quick_tutorial/package.rst b/docs/quick_tutorial/package.rst index 9e175bdaaf..6a379032ee 100644 --- a/docs/quick_tutorial/package.rst +++ b/docs/quick_tutorial/package.rst @@ -10,7 +10,7 @@ Background ========== Python developers can organize a collection of modules and files into a -namespaced unit called a :ref:`package `. If a +namespaced unit called a :ref:`package `. If a directory is on ``sys.path`` and has a special file named ``__init__.py``, it is treated as a Python package. @@ -102,6 +102,6 @@ of an odd duck. We would never do this unless we were writing a tutorial that tries to capture how this stuff works a step at a time. It's generally a bad idea to run a Python module inside a package directly as a script. -.. seealso:: :ref:`Python Packages ` and `Working in +.. seealso:: :ref:`Python Packages ` and `Working in "Development Mode" `_. diff --git a/docs/quick_tutorial/requirements.rst b/docs/quick_tutorial/requirements.rst index 3373ba2bc2..299ad2ac0b 100644 --- a/docs/quick_tutorial/requirements.rst +++ b/docs/quick_tutorial/requirements.rst @@ -178,7 +178,7 @@ we just specified in the environment variable. # Windows c:\> c:\Python35\python -m venv %VENV% -.. seealso:: See also Python 3's :mod:`venv module ` and Python +.. seealso:: See also Python 3's :mod:`venv module ` and Python 2's `virtualenv `_ package. From 21fd514e069f9d172ac0f96febd721ed93917ae3 Mon Sep 17 00:00:00 2001 From: Steve Piercy Date: Thu, 7 Apr 2016 03:12:27 -0700 Subject: [PATCH 011/102] - update ini.rst --- docs/quick_tutorial/ini.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/quick_tutorial/ini.rst b/docs/quick_tutorial/ini.rst index 36942c767f..0aed304df1 100644 --- a/docs/quick_tutorial/ini.rst +++ b/docs/quick_tutorial/ini.rst @@ -50,7 +50,7 @@ Steps .. code-block:: bash - $ $VENV/bin/python setup.py develop + $ $VENV/bin/pip install -e . #. Let's make a file ``ini/development.ini`` for our configuration: From ba78808ec3749aeb6bf5512c06a7999abeacd08f Mon Sep 17 00:00:00 2001 From: Steve Piercy Date: Thu, 7 Apr 2016 03:14:04 -0700 Subject: [PATCH 012/102] - update debugtoolbar --- docs/quick_tutorial/debugtoolbar.rst | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/docs/quick_tutorial/debugtoolbar.rst b/docs/quick_tutorial/debugtoolbar.rst index f11abc4933..1f89cd3193 100644 --- a/docs/quick_tutorial/debugtoolbar.rst +++ b/docs/quick_tutorial/debugtoolbar.rst @@ -4,8 +4,7 @@ 04: Easier Development with ``debugtoolbar`` ============================================ -Error-handling and introspection using the ``pyramid_debugtoolbar`` -add-on. +Error handling and introspection using the ``pyramid_debugtoolbar`` add-on. Background ========== @@ -36,8 +35,8 @@ Steps .. code-block:: bash $ cd ..; cp -r ini debugtoolbar; cd debugtoolbar - $ $VENV/bin/python setup.py develop - $ $VENV/bin/easy_install pyramid_debugtoolbar + $ $VENV/bin/pip install -e . + $ $VENV/bin/pip install pyramid_debugtoolbar #. Our ``debugtoolbar/development.ini`` gets a configuration entry for ``pyramid.includes``: From d68cbc6f69446317bc8b01062609c4779624cfc5 Mon Sep 17 00:00:00 2001 From: Steve Piercy Date: Thu, 7 Apr 2016 03:15:45 -0700 Subject: [PATCH 013/102] - update unit_testing.rst --- docs/quick_tutorial/unit_testing.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/quick_tutorial/unit_testing.rst b/docs/quick_tutorial/unit_testing.rst index 4cb7ef7148..58512d1cc2 100644 --- a/docs/quick_tutorial/unit_testing.rst +++ b/docs/quick_tutorial/unit_testing.rst @@ -48,8 +48,8 @@ Steps .. code-block:: bash $ cd ..; cp -r debugtoolbar unit_testing; cd unit_testing - $ $VENV/bin/python setup.py develop - $ $VENV/bin/easy_install nose + $ $VENV/bin/pip install -e . + $ $VENV/bin/pip install nose #. Now we write a simple unit test in ``unit_testing/tutorial/tests.py``: From 9459d8c11a1bd8d62c84c7ff1f761c6aead61510 Mon Sep 17 00:00:00 2001 From: Steve Piercy Date: Thu, 7 Apr 2016 03:17:03 -0700 Subject: [PATCH 014/102] - update functional_testing.rst --- docs/quick_tutorial/functional_testing.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/quick_tutorial/functional_testing.rst b/docs/quick_tutorial/functional_testing.rst index 6f1544e792..b8aa7e87db 100644 --- a/docs/quick_tutorial/functional_testing.rst +++ b/docs/quick_tutorial/functional_testing.rst @@ -34,8 +34,8 @@ Steps .. code-block:: bash $ cd ..; cp -r unit_testing functional_testing; cd functional_testing - $ $VENV/bin/python setup.py develop - $ $VENV/bin/easy_install webtest + $ $VENV/bin/pip install -e . + $ $VENV/bin/pip install webtest #. Let's extend ``functional_testing/tutorial/tests.py`` to include a functional test: From 010b7cf0e08f1d9815e66fc915bf7412df699f1f Mon Sep 17 00:00:00 2001 From: Steve Piercy Date: Thu, 7 Apr 2016 03:18:24 -0700 Subject: [PATCH 015/102] - update views.rst --- docs/quick_tutorial/views.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/quick_tutorial/views.rst b/docs/quick_tutorial/views.rst index 6728925fd3..5b6e2960b6 100644 --- a/docs/quick_tutorial/views.rst +++ b/docs/quick_tutorial/views.rst @@ -43,7 +43,7 @@ Steps .. code-block:: bash $ cd ..; cp -r functional_testing views; cd views - $ $VENV/bin/python setup.py develop + $ $VENV/bin/pip install -e . #. Our ``views/tutorial/__init__.py`` gets a lot shorter: From 96ca13ad07593fe15c8981e8a0372d749f6bd411 Mon Sep 17 00:00:00 2001 From: Steve Piercy Date: Thu, 7 Apr 2016 03:19:59 -0700 Subject: [PATCH 016/102] - update templating.rst --- docs/quick_tutorial/jinja2.rst | 2 +- docs/quick_tutorial/templating.rst | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/quick_tutorial/jinja2.rst b/docs/quick_tutorial/jinja2.rst index 2121803f97..8622e968a5 100644 --- a/docs/quick_tutorial/jinja2.rst +++ b/docs/quick_tutorial/jinja2.rst @@ -27,7 +27,7 @@ Steps $ cd ..; cp -r view_classes jinja2; cd jinja2 $ $VENV/bin/python setup.py develop - $ $VENV/bin/easy_install pyramid_jinja2 + $ $VENV/bin/pip install pyramid_jinja2 #. We need to include ``pyramid_jinja2`` in ``jinja2/tutorial/__init__.py``: diff --git a/docs/quick_tutorial/templating.rst b/docs/quick_tutorial/templating.rst index cf56d2a969..a975d9ec25 100644 --- a/docs/quick_tutorial/templating.rst +++ b/docs/quick_tutorial/templating.rst @@ -56,7 +56,7 @@ Steps .. code-block:: bash - $ $VENV/bin/python setup.py develop + $ $VENV/bin/pip install -e . #. We need to connect ``pyramid_chameleon`` as a renderer by making a call in the setup of ``templating/tutorial/__init__.py``: From fd965fe8bfb62a467521e3883237b0506296b7b4 Mon Sep 17 00:00:00 2001 From: Steve Piercy Date: Thu, 7 Apr 2016 03:21:14 -0700 Subject: [PATCH 017/102] - update view_classes.rst --- docs/quick_tutorial/view_classes.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/quick_tutorial/view_classes.rst b/docs/quick_tutorial/view_classes.rst index 6198eed633..cc53374934 100644 --- a/docs/quick_tutorial/view_classes.rst +++ b/docs/quick_tutorial/view_classes.rst @@ -41,7 +41,7 @@ Steps .. code-block:: bash $ cd ..; cp -r templating view_classes; cd view_classes - $ $VENV/bin/python setup.py develop + $ $VENV/bin/pip install -e . #. Our ``view_classes/tutorial/views.py`` now has a view class with our two views: From 5e088cc17818cf3921c3634ca4e35011525e4076 Mon Sep 17 00:00:00 2001 From: Steve Piercy Date: Thu, 7 Apr 2016 03:22:20 -0700 Subject: [PATCH 018/102] - update request_response.rst --- docs/quick_tutorial/request_response.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/quick_tutorial/request_response.rst b/docs/quick_tutorial/request_response.rst index 4f8de02213..f42423de85 100644 --- a/docs/quick_tutorial/request_response.rst +++ b/docs/quick_tutorial/request_response.rst @@ -41,7 +41,7 @@ Steps .. code-block:: bash $ cd ..; cp -r view_classes request_response; cd request_response - $ $VENV/bin/python setup.py develop + $ $VENV/bin/pip install -e . #. Simplify the routes in ``request_response/tutorial/__init__.py``: From e612f1ef16a25febbb61ed1b12634c814b251d83 Mon Sep 17 00:00:00 2001 From: Steve Piercy Date: Thu, 7 Apr 2016 03:23:47 -0700 Subject: [PATCH 019/102] - update routing.rst --- docs/quick_tutorial/routing.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/quick_tutorial/routing.rst b/docs/quick_tutorial/routing.rst index 416a346fa5..7b6d0904d7 100644 --- a/docs/quick_tutorial/routing.rst +++ b/docs/quick_tutorial/routing.rst @@ -48,7 +48,7 @@ Steps .. code-block:: bash $ cd ..; cp -r view_classes routing; cd routing - $ $VENV/bin/python setup.py develop + $ $VENV/bin/pip install -e . #. Our ``routing/tutorial/__init__.py`` needs a route with a replacement pattern: From 45fabb70bf376b4ee1ae6594be71577f4e3ebb08 Mon Sep 17 00:00:00 2001 From: Steve Piercy Date: Thu, 7 Apr 2016 03:24:59 -0700 Subject: [PATCH 020/102] - update jinja2.rst --- docs/quick_tutorial/jinja2.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/quick_tutorial/jinja2.rst b/docs/quick_tutorial/jinja2.rst index 8622e968a5..6b9d5feba2 100644 --- a/docs/quick_tutorial/jinja2.rst +++ b/docs/quick_tutorial/jinja2.rst @@ -26,7 +26,7 @@ Steps .. code-block:: bash $ cd ..; cp -r view_classes jinja2; cd jinja2 - $ $VENV/bin/python setup.py develop + $ $VENV/bin/pip install -e . $ $VENV/bin/pip install pyramid_jinja2 #. We need to include ``pyramid_jinja2`` in From 2d2ced28cd261b0080bcec9f101432b4fe40c13b Mon Sep 17 00:00:00 2001 From: Steve Piercy Date: Thu, 7 Apr 2016 03:26:06 -0700 Subject: [PATCH 021/102] - update static_assets.rst --- docs/quick_tutorial/static_assets.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/quick_tutorial/static_assets.rst b/docs/quick_tutorial/static_assets.rst index 3a7496ec71..61c5fbd508 100644 --- a/docs/quick_tutorial/static_assets.rst +++ b/docs/quick_tutorial/static_assets.rst @@ -23,7 +23,7 @@ Steps .. code-block:: bash $ cd ..; cp -r view_classes static_assets; cd static_assets - $ $VENV/bin/python setup.py develop + $ $VENV/bin/pip install -e . #. We add a call ``config.add_static_view`` in ``static_assets/tutorial/__init__.py``: From b37b6f4b5393191047edf44173d3d8c2581861a7 Mon Sep 17 00:00:00 2001 From: Steve Piercy Date: Thu, 7 Apr 2016 03:26:52 -0700 Subject: [PATCH 022/102] - update json.rst --- docs/quick_tutorial/json.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/quick_tutorial/json.rst b/docs/quick_tutorial/json.rst index aa789d8336..49421829b5 100644 --- a/docs/quick_tutorial/json.rst +++ b/docs/quick_tutorial/json.rst @@ -31,7 +31,7 @@ Steps .. code-block:: bash $ cd ..; cp -r view_classes json; cd json - $ $VENV/bin/python setup.py develop + $ $VENV/bin/pip install -e . #. We add a new route for ``hello_json`` in ``json/tutorial/__init__.py``: From 9f66915a3878ad9764b8fd5039465db54f7a47c1 Mon Sep 17 00:00:00 2001 From: Steve Piercy Date: Thu, 7 Apr 2016 03:27:57 -0700 Subject: [PATCH 023/102] - update more_view_classes.rst --- docs/quick_tutorial/more_view_classes.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/quick_tutorial/more_view_classes.rst b/docs/quick_tutorial/more_view_classes.rst index afbb7cc3ab..fb97cceb23 100644 --- a/docs/quick_tutorial/more_view_classes.rst +++ b/docs/quick_tutorial/more_view_classes.rst @@ -57,7 +57,7 @@ Steps .. code-block:: bash $ cd ..; cp -r templating more_view_classes; cd more_view_classes - $ $VENV/bin/python setup.py develop + $ $VENV/bin/pip install -e . #. Our route in ``more_view_classes/tutorial/__init__.py`` needs some replacement patterns: From 14fd6dc1d9b74b2ea0034d9c485e50ad9bcbbecf Mon Sep 17 00:00:00 2001 From: Steve Piercy Date: Thu, 7 Apr 2016 03:28:38 -0700 Subject: [PATCH 024/102] - update logging.rst --- docs/quick_tutorial/logging.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/quick_tutorial/logging.rst b/docs/quick_tutorial/logging.rst index 5d29cd1961..556a09bf01 100644 --- a/docs/quick_tutorial/logging.rst +++ b/docs/quick_tutorial/logging.rst @@ -35,7 +35,7 @@ Steps .. code-block:: bash $ cd ..; cp -r view_classes logging; cd logging - $ $VENV/bin/python setup.py develop + $ $VENV/bin/pip install -e . #. Extend ``logging/tutorial/views.py`` to log a message: From 6e45624d143631aafc808d97cff66263e6152ed5 Mon Sep 17 00:00:00 2001 From: Steve Piercy Date: Thu, 7 Apr 2016 03:29:16 -0700 Subject: [PATCH 025/102] - update sessions.rst --- docs/quick_tutorial/sessions.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/quick_tutorial/sessions.rst b/docs/quick_tutorial/sessions.rst index f97405500d..06176f2b6d 100644 --- a/docs/quick_tutorial/sessions.rst +++ b/docs/quick_tutorial/sessions.rst @@ -34,7 +34,7 @@ Steps .. code-block:: bash $ cd ..; cp -r view_classes sessions; cd sessions - $ $VENV/bin/python setup.py develop + $ $VENV/bin/pip install -e . #. Our ``sessions/tutorial/__init__.py`` needs a choice of session factory to get registered with the :term:`configurator`: From 9845f718ccd609b6ecf514b165a4fd2f9dfb8d8c Mon Sep 17 00:00:00 2001 From: Steve Piercy Date: Thu, 7 Apr 2016 03:30:26 -0700 Subject: [PATCH 026/102] - update forms.rst --- docs/quick_tutorial/forms.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/quick_tutorial/forms.rst b/docs/quick_tutorial/forms.rst index f81b88fc24..023e7127f2 100644 --- a/docs/quick_tutorial/forms.rst +++ b/docs/quick_tutorial/forms.rst @@ -50,7 +50,7 @@ Steps .. code-block:: bash - $ $VENV/bin/python setup.py develop + $ $VENV/bin/pip install -e . #. Register a static view in ``forms/tutorial/__init__.py`` for Deform's CSS/JS etc. as well as our demo wikipage scenario's From a42b09be68e52d8204bc0f3c18697bb2020f8fc4 Mon Sep 17 00:00:00 2001 From: Steve Piercy Date: Thu, 7 Apr 2016 03:31:34 -0700 Subject: [PATCH 027/102] - update databases.rst --- docs/quick_tutorial/databases.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/quick_tutorial/databases.rst b/docs/quick_tutorial/databases.rst index 19dfd066df..311ff6ec5f 100644 --- a/docs/quick_tutorial/databases.rst +++ b/docs/quick_tutorial/databases.rst @@ -53,7 +53,7 @@ Steps .. note:: - We aren't yet doing ``$VENV/bin/python setup.py develop`` as we + We aren't yet doing ``$VENV/bin/pip install -e .`` as we will change it later. #. Our configuration file at ``databases/development.ini`` wires @@ -78,7 +78,7 @@ Steps .. code-block:: bash - $ $VENV/bin/python setup.py develop + $ $VENV/bin/pip install -e . #. The script references some models in ``databases/tutorial/models.py``: From 2c8511fffc2914480646ab5afb47d12c44ffc6a3 Mon Sep 17 00:00:00 2001 From: Steve Piercy Date: Thu, 7 Apr 2016 03:32:19 -0700 Subject: [PATCH 028/102] - update authentication.rst --- docs/quick_tutorial/authentication.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/quick_tutorial/authentication.rst b/docs/quick_tutorial/authentication.rst index 7fd8173d45..5b4a6224d6 100644 --- a/docs/quick_tutorial/authentication.rst +++ b/docs/quick_tutorial/authentication.rst @@ -33,7 +33,7 @@ Steps .. code-block:: bash $ cd ..; cp -r view_classes authentication; cd authentication - $ $VENV/bin/python setup.py develop + $ $VENV/bin/pip install -e . #. Put the security hash in the ``authentication/development.ini`` configuration file as ``tutorial.secret`` instead of putting it in From d9c4cbb73b974db2973985369493efe0aec63737 Mon Sep 17 00:00:00 2001 From: Steve Piercy Date: Thu, 7 Apr 2016 03:34:05 -0700 Subject: [PATCH 029/102] - update authorization.rst - add intersphinx target links --- docs/quick_tutorial/authentication.rst | 2 ++ docs/quick_tutorial/authorization.rst | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/quick_tutorial/authentication.rst b/docs/quick_tutorial/authentication.rst index 5b4a6224d6..cb3839b082 100644 --- a/docs/quick_tutorial/authentication.rst +++ b/docs/quick_tutorial/authentication.rst @@ -1,3 +1,5 @@ +.. _qtut_authentication: + ============================== 20: Logins With Authentication ============================== diff --git a/docs/quick_tutorial/authorization.rst b/docs/quick_tutorial/authorization.rst index 855043f7ff..a4a12774be 100644 --- a/docs/quick_tutorial/authorization.rst +++ b/docs/quick_tutorial/authorization.rst @@ -1,3 +1,5 @@ +.. _qtut_authorization: + =========================================== 21: Protecting Resources With Authorization =========================================== @@ -38,7 +40,7 @@ Steps .. code-block:: bash $ cd ..; cp -r authentication authorization; cd authorization - $ $VENV/bin/python setup.py develop + $ $VENV/bin/pip install -e . #. Start by changing ``authorization/tutorial/__init__.py`` to specify a root factory to the :term:`configurator`: From 3c6d7e587142a884710cc4a41c12c7b26547fc44 Mon Sep 17 00:00:00 2001 From: Steve Piercy Date: Thu, 7 Apr 2016 15:58:14 -0700 Subject: [PATCH 030/102] replace easy_install/setup.py with pip --- docs/tutorials/modwsgi/index.rst | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/docs/tutorials/modwsgi/index.rst b/docs/tutorials/modwsgi/index.rst index ddd9689276..1a149b44a4 100644 --- a/docs/tutorials/modwsgi/index.rst +++ b/docs/tutorials/modwsgi/index.rst @@ -1,7 +1,7 @@ .. _modwsgi_tutorial: Running a :app:`Pyramid` Application under ``mod_wsgi`` -========================================================== +======================================================= :term:`mod_wsgi` is an Apache module developed by Graham Dumpleton. It allows :term:`WSGI` programs to be served using the Apache web @@ -30,11 +30,11 @@ specific path information for commands and files. for your platform into your system's Apache installation. #. Install :term:`virtualenv` into the Python which mod_wsgi will - run using the ``easy_install`` program. + run using pip. .. code-block:: text - $ sudo /usr/bin/easy_install-2.6 virtualenv + $ sudo /usr/bin/pip install virtualenv This command may need to be performed as the root user. @@ -53,7 +53,7 @@ specific path information for commands and files. .. code-block:: text $ cd ~/modwsgi/env - $ $VENV/bin/easy_install pyramid + $ $VENV/bin/pip install pyramid #. Create and install your :app:`Pyramid` application. For the purposes of this tutorial, we'll just be using the ``pyramid_starter`` application as @@ -65,7 +65,7 @@ specific path information for commands and files. $ cd ~/modwsgi/env $ $VENV/bin/pcreate -s starter myapp $ cd myapp - $ $VENV/bin/python setup.py install + $ $VENV/bin/pip install -e . #. Within the virtualenv directory (``~/modwsgi/env``), create a script named ``pyramid.wsgi``. Give it these contents: @@ -131,4 +131,3 @@ serve up a :app:`Pyramid` application. See the `mod_wsgi configuration documentation `_ for more in-depth configuration information. - From e551a4f026c1522ba4045cfb1799d050bdb072bc Mon Sep 17 00:00:00 2001 From: Steve Piercy Date: Fri, 8 Apr 2016 04:43:08 -0700 Subject: [PATCH 031/102] rough draft for wiki2, replace setup.py with pip. See #2104. --- docs/tutorials/wiki2/installation.rst | 206 ++++++++++++++++++-------- 1 file changed, 148 insertions(+), 58 deletions(-) diff --git a/docs/tutorials/wiki2/installation.rst b/docs/tutorials/wiki2/installation.rst index b263ccbd9e..ca7b8ae8ad 100644 --- a/docs/tutorials/wiki2/installation.rst +++ b/docs/tutorials/wiki2/installation.rst @@ -72,8 +72,8 @@ Python 3.5: c:\> c:\Python35\Scripts\virtualenv %VENV% -Upgrade pip in the virtual environment --------------------------------------- +Upgrade ``pip`` in the virtual environment +------------------------------------------ On UNIX ^^^^^^^ @@ -187,16 +187,15 @@ On Windows and the project into directories that do not contain spaces in their paths. - .. _installing_project_in_dev_mode: Installing the project in development mode ------------------------------------------ In order to do development on the project easily, you must "register" the -project as a development egg in your workspace using the ``setup.py develop`` +project as a development egg in your workspace using the ``pip install -e .`` command. In order to do so, change directory to the ``tutorial`` directory that -you created in :ref:`sql_making_a_project`, and run the ``setup.py develop`` +you created in :ref:`sql_making_a_project`, and run the ``pip install -e .`` command using the virtualenv Python interpreter. On UNIX @@ -215,25 +214,130 @@ On Windows c:\pyramidtut> cd tutorial c:\pyramidtut\tutorial> %VENV%\Scripts\pip install -e . -The console will show ``setup.py`` checking for packages and installing missing -packages. Success executing this command will show a line like the following:: +The console will show ``pip`` checking for packages and installing missing +packages. Success executing this command will show a line like the following: + +.. code-block:: bash + + Successfully installed Chameleon-2.24 Mako-1.0.4 MarkupSafe-0.23 \ + Pygments-2.1.3 SQLAlchemy-1.0.12 pyramid-chameleon-0.3 \ + pyramid-debugtoolbar-2.4.2 pyramid-mako-1.0.2 pyramid-tm-0.12.1 \ + transaction-1.4.4 tutorial waitress-0.8.10 zope.sqlalchemy-0.7.6 + + +.. _install-testing-requirements: + +Install testing requirements +---------------------------- + +In order to run tests, we need to install the testing requirements, which means +we need to edit our ``setup.py``: + +.. .. literalinclude:: src/installation/setup.py + :language: py + :linenos: + :emphasize-lines: 23-30,50-52 + +.. code-block:: python + :linenos: + :emphasize-lines: 23-29,49-51 + + import os + + from setuptools import setup, find_packages + + here = os.path.abspath(os.path.dirname(__file__)) + with open(os.path.join(here, 'README.txt')) as f: + README = f.read() + with open(os.path.join(here, 'CHANGES.txt')) as f: + CHANGES = f.read() + + requires = [ + 'pyramid', + 'pyramid_jinja2', + 'pyramid_debugtoolbar', + 'pyramid_tm', + 'SQLAlchemy', + 'transaction', + 'zope.sqlalchemy', + 'waitress', + ] + + tests_require = [ + 'WebTest >= 1.3.1', # py3 compat + ] + + testing_extras = tests_require + [ + 'pytest', # includes virtualenv + 'pytest-cov', + ] + + setup(name='tutorial', + version='0.0', + description='tutorial', + long_description=README + '\n\n' + CHANGES, + classifiers=[ + "Programming Language :: Python", + "Framework :: Pyramid", + "Topic :: Internet :: WWW/HTTP", + "Topic :: Internet :: WWW/HTTP :: WSGI :: Application", + ], + author='', + author_email='', + url='', + keywords='web wsgi bfg pylons pyramid', + packages=find_packages(), + include_package_data=True, + zip_safe=False, + test_suite='tutorial', + extras_require={ + 'testing': testing_extras, + }, + tests_require=tests_require, + install_requires=requires, + entry_points="""\ + [paste.app_factory] + main = tutorial:main + [console_scripts] + initialize_tutorial_db = tutorial.scripts.initializedb:main + """, + ) + +Only the emphasized lines need to be edited. + +Next install the testing requirements. + +On UNIX +^^^^^^^ + +.. code-block:: bash + + $ $VENV/bin/pip install -e ".[testing]" + +On Windows +^^^^^^^^^^ + +.. code-block:: ps1con + + c:\pyramidtut\tutorial> %VENV%\Scripts\pip install -e ".[testing]" - Finished processing dependencies for tutorial==0.0 .. _sql_running_tests: Run the tests ------------- -After you've installed the project in development mode, you may run the tests -for the project. +After you've installed the project in development mode as well as the testing +requirements, you may run the tests for the project. On UNIX ^^^^^^^ .. code-block:: bash - $ $VENV/bin/python setup.py test -q + $ $VENV/bin/py.test tutorial/tests.py -q + +.. TODO remove comments .. py.test? See https://github.com/Pylons/pyramid/issues/2104#issuecomment-155852046 @@ -242,79 +346,65 @@ On Windows .. code-block:: ps1con - c:\pyramidtut\tutorial> %VENV%\Scripts\python setup.py test -q + c:\pyramidtut\tutorial> %VENV%\Scripts\py.test tutorial\tests.py -q .. py.test? See https://github.com/Pylons/pyramid/issues/2104#issuecomment-155852046 -For a successful test run, you should see output that ends like this:: +For a successful test run, you should see output that ends like this: + +.. code-block:: bash .. - ---------------------------------------------------------------------- - Ran 2 tests in 0.053s + 2 passed in 0.44 seconds - OK Expose test coverage information -------------------------------- -You can run the ``nosetests`` command to see test coverage information. This -runs the tests in the same way that ``setup.py test`` does, but provides -additional "coverage" information, exposing which lines of your project are -covered by the tests. +You can run the ``py.test`` command to see test coverage information. This +runs the tests in the same way that ``py.test`` does, but provides additional +"coverage" information, exposing which lines of your project are covered by the +tests. -To get this functionality working, we'll need to install the ``nose`` and -``coverage`` packages into our ``virtualenv``: +We've already installed the ``pytest-cov`` package into our ``virtualenv``, so +we can run the tests with coverage. On UNIX ^^^^^^^ .. code-block:: bash - $ $VENV/bin/easy_install nose coverage + $ $VENV/bin/py.test --cov=tutorial tutorial/tests.py On Windows ^^^^^^^^^^ .. code-block:: ps1con - c:\pyramidtut\tutorial> %VENV%\Scripts\easy_install nose coverage - -Once ``nose`` and ``coverage`` are installed, we can run the tests with -coverage. - -On UNIX -^^^^^^^ - -.. code-block:: bash - - $ $VENV/bin/nosetests --cover-package=tutorial --cover-erase --with-coverage - -On Windows -^^^^^^^^^^ - -.. code-block:: ps1con - - c:\pyramidtut\tutorial> %VENV%\Scripts\nosetests --cover-package=tutorial \ - --cover-erase --with-coverage + c:\pyramidtut\tutorial> %VENV%\Scripts\py.test --cov=tutorial tutorial\tests.py If successful, you will see output something like this:: - .. - Name Stmts Miss Cover Missing - ---------------------------------------------------------- - tutorial.py 8 6 25% 7-12 - tutorial/models.py 22 0 100% - tutorial/models/meta.py 5 0 100% - tutorial/models/mymodel.py 8 0 100% - tutorial/scripts.py 0 0 100% - tutorial/views.py 0 0 100% - tutorial/views/default.py 12 0 100% - ---------------------------------------------------------- - TOTAL 55 6 89% - ---------------------------------------------------------------------- - Ran 2 tests in 0.579s - - OK +======================== test session starts ======================== +platform Python 3.5.1, pytest-2.9.1, py-1.4.31, pluggy-0.3.1 +rootdir: /Users/stevepiercy/projects/pyramidtut/tutorial, inifile: +plugins: cov-2.2.1 +collected 2 items + +tutorial/tests.py .. +------------------ coverage: platform Python 3.5.1 ------------------ +Name Stmts Miss Cover +------------------------------------------------------ +tutorial/__init__.py 13 9 31% +tutorial/models.py 12 0 100% +tutorial/scripts/__init__.py 0 0 100% +tutorial/scripts/initializedb.py 24 24 0% +tutorial/tests.py 39 0 100% +tutorial/views.py 11 0 100% +------------------------------------------------------ +TOTAL 99 33 67% + +===================== 2 passed in 0.57 seconds ====================== Our package doesn't quite have 100% test coverage. From 25c809968d16fbaa07f667713fd35d64d34de877 Mon Sep 17 00:00:00 2001 From: Steve Piercy Date: Fri, 8 Apr 2016 04:46:45 -0700 Subject: [PATCH 032/102] fix syntax highlighting --- docs/tutorials/wiki2/installation.rst | 46 ++++++++++++++------------- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/docs/tutorials/wiki2/installation.rst b/docs/tutorials/wiki2/installation.rst index ca7b8ae8ad..d6745e7582 100644 --- a/docs/tutorials/wiki2/installation.rst +++ b/docs/tutorials/wiki2/installation.rst @@ -383,28 +383,30 @@ On Windows c:\pyramidtut\tutorial> %VENV%\Scripts\py.test --cov=tutorial tutorial\tests.py -If successful, you will see output something like this:: - -======================== test session starts ======================== -platform Python 3.5.1, pytest-2.9.1, py-1.4.31, pluggy-0.3.1 -rootdir: /Users/stevepiercy/projects/pyramidtut/tutorial, inifile: -plugins: cov-2.2.1 -collected 2 items - -tutorial/tests.py .. ------------------- coverage: platform Python 3.5.1 ------------------ -Name Stmts Miss Cover ------------------------------------------------------- -tutorial/__init__.py 13 9 31% -tutorial/models.py 12 0 100% -tutorial/scripts/__init__.py 0 0 100% -tutorial/scripts/initializedb.py 24 24 0% -tutorial/tests.py 39 0 100% -tutorial/views.py 11 0 100% ------------------------------------------------------- -TOTAL 99 33 67% - -===================== 2 passed in 0.57 seconds ====================== +If successful, you will see output something like this: + +.. code-block:: bash + + ======================== test session starts ======================== + platform Python 3.5.1, pytest-2.9.1, py-1.4.31, pluggy-0.3.1 + rootdir: /Users/stevepiercy/projects/pyramidtut/tutorial, inifile: + plugins: cov-2.2.1 + collected 2 items + + tutorial/tests.py .. + ------------------ coverage: platform Python 3.5.1 ------------------ + Name Stmts Miss Cover + ------------------------------------------------------ + tutorial/__init__.py 13 9 31% + tutorial/models.py 12 0 100% + tutorial/scripts/__init__.py 0 0 100% + tutorial/scripts/initializedb.py 24 24 0% + tutorial/tests.py 39 0 100% + tutorial/views.py 11 0 100% + ------------------------------------------------------ + TOTAL 99 33 67% + + ===================== 2 passed in 0.57 seconds ====================== Our package doesn't quite have 100% test coverage. From aa51dcc629028fda64ee83340d9b3981be7fbb29 Mon Sep 17 00:00:00 2001 From: Steve Piercy Date: Fri, 8 Apr 2016 05:14:31 -0700 Subject: [PATCH 033/102] use `--cov-report=term-missing` --- docs/tutorials/wiki2/installation.rst | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/docs/tutorials/wiki2/installation.rst b/docs/tutorials/wiki2/installation.rst index d6745e7582..70c77f57fd 100644 --- a/docs/tutorials/wiki2/installation.rst +++ b/docs/tutorials/wiki2/installation.rst @@ -374,14 +374,15 @@ On UNIX .. code-block:: bash - $ $VENV/bin/py.test --cov=tutorial tutorial/tests.py + $ $VENV/bin/py.test --cov=tutorial --cov-report=term-missing tutorial/tests.py On Windows ^^^^^^^^^^ .. code-block:: ps1con - c:\pyramidtut\tutorial> %VENV%\Scripts\py.test --cov=tutorial tutorial\tests.py + c:\pyramidtut\tutorial> %VENV%\Scripts\py.test --cov=tutorial \ + --cov-report=term-missing tutorial\tests.py If successful, you will see output something like this: @@ -395,15 +396,15 @@ If successful, you will see output something like this: tutorial/tests.py .. ------------------ coverage: platform Python 3.5.1 ------------------ - Name Stmts Miss Cover - ------------------------------------------------------ - tutorial/__init__.py 13 9 31% + Name Stmts Miss Cover Missing + ---------------------------------------------------------------- + tutorial/__init__.py 13 9 31% 13-21 tutorial/models.py 12 0 100% tutorial/scripts/__init__.py 0 0 100% - tutorial/scripts/initializedb.py 24 24 0% + tutorial/scripts/initializedb.py 24 24 0% 1-40 tutorial/tests.py 39 0 100% tutorial/views.py 11 0 100% - ------------------------------------------------------ + ---------------------------------------------------------------- TOTAL 99 33 67% ===================== 2 passed in 0.57 seconds ====================== From c239c4a68b41dab9d3f4477ea7de6431ec7548dd Mon Sep 17 00:00:00 2001 From: Steve Piercy Date: Fri, 8 Apr 2016 12:50:10 -0700 Subject: [PATCH 034/102] simplify test dependencies per https://github.com/Pylons/pyramid/pull/2442/files/aa51dcc629028fda64ee83340d9b3981be7fbb29#r59052781 --- docs/tutorials/wiki2/installation.rst | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/docs/tutorials/wiki2/installation.rst b/docs/tutorials/wiki2/installation.rst index 70c77f57fd..221b62ecef 100644 --- a/docs/tutorials/wiki2/installation.rst +++ b/docs/tutorials/wiki2/installation.rst @@ -263,11 +263,8 @@ we need to edit our ``setup.py``: 'waitress', ] - tests_require = [ + testing_extras = [ 'WebTest >= 1.3.1', # py3 compat - ] - - testing_extras = tests_require + [ 'pytest', # includes virtualenv 'pytest-cov', ] @@ -293,7 +290,6 @@ we need to edit our ``setup.py``: extras_require={ 'testing': testing_extras, }, - tests_require=tests_require, install_requires=requires, entry_points="""\ [paste.app_factory] From 3c0d2ead8e7b54ac2a3b31e3589b676b2cc97a53 Mon Sep 17 00:00:00 2001 From: Steve Piercy Date: Fri, 8 Apr 2016 12:52:07 -0700 Subject: [PATCH 035/102] adjust line numbers for emphasis --- docs/tutorials/wiki2/installation.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/tutorials/wiki2/installation.rst b/docs/tutorials/wiki2/installation.rst index 221b62ecef..2ea0c83393 100644 --- a/docs/tutorials/wiki2/installation.rst +++ b/docs/tutorials/wiki2/installation.rst @@ -240,7 +240,7 @@ we need to edit our ``setup.py``: .. code-block:: python :linenos: - :emphasize-lines: 23-29,49-51 + :emphasize-lines: 22-26,46-48 import os From 9b61be1feebe26c4943232997ccbdecfb2272cc7 Mon Sep 17 00:00:00 2001 From: Steve Piercy Date: Fri, 8 Apr 2016 13:36:01 -0700 Subject: [PATCH 036/102] removed test_suite line. ping @mmerickel @bertjwregeer --- docs/tutorials/wiki2/installation.rst | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/tutorials/wiki2/installation.rst b/docs/tutorials/wiki2/installation.rst index 2ea0c83393..bd52b8f7a3 100644 --- a/docs/tutorials/wiki2/installation.rst +++ b/docs/tutorials/wiki2/installation.rst @@ -286,7 +286,6 @@ we need to edit our ``setup.py``: packages=find_packages(), include_package_data=True, zip_safe=False, - test_suite='tutorial', extras_require={ 'testing': testing_extras, }, From 9b0730733d29fd88b2358ad8ac08eb4761fc5e93 Mon Sep 17 00:00:00 2001 From: Steve Piercy Date: Sat, 9 Apr 2016 00:50:42 -0700 Subject: [PATCH 037/102] update alchemy scaffold's setup.py to allow use of pip. See #2104. --- pyramid/scaffolds/alchemy/setup.py_tmpl | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/pyramid/scaffolds/alchemy/setup.py_tmpl b/pyramid/scaffolds/alchemy/setup.py_tmpl index d837ea0a9b..9deed9e8a5 100644 --- a/pyramid/scaffolds/alchemy/setup.py_tmpl +++ b/pyramid/scaffolds/alchemy/setup.py_tmpl @@ -19,20 +19,22 @@ requires = [ 'waitress', ] -tests_require = [ - 'WebTest', -] +testing_extras = [ + 'WebTest >= 1.3.1', # py3 compat + 'pytest', # includes virtualenv + 'pytest-cov', + ] setup(name='{{project}}', version='0.0', description='{{project}}', long_description=README + '\n\n' + CHANGES, classifiers=[ - "Programming Language :: Python", - "Framework :: Pyramid", - "Topic :: Internet :: WWW/HTTP", - "Topic :: Internet :: WWW/HTTP :: WSGI :: Application", - ], + "Programming Language :: Python", + "Framework :: Pyramid", + "Topic :: Internet :: WWW/HTTP", + "Topic :: Internet :: WWW/HTTP :: WSGI :: Application", + ], author='', author_email='', url='', @@ -40,8 +42,9 @@ setup(name='{{project}}', packages=find_packages(), include_package_data=True, zip_safe=False, - test_suite='{{package}}', - tests_require=tests_require, + extras_require={ + 'testing': testing_extras, + }, install_requires=requires, entry_points="""\ [paste.app_factory] From b50a19224bbd2b1600e956f83e60bdb5ea908dd4 Mon Sep 17 00:00:00 2001 From: Steve Piercy Date: Sat, 9 Apr 2016 00:52:23 -0700 Subject: [PATCH 038/102] add result of installation step in wiki2 tutorial, but using the recently updated scaffold from master and normalize its version to 1.7. See #2104. --- .../wiki2/src/installation/CHANGES.txt | 4 + .../src/installation/tutorial/__init__.py | 12 ++ .../installation/tutorial/models/__init__.py | 73 +++++++++ .../src/installation/tutorial/models/meta.py | 16 ++ .../installation/tutorial/models/mymodel.py | 18 ++ .../wiki2/src/installation/tutorial/routes.py | 3 + .../installation/tutorial/scripts/__init__.py | 1 + .../tutorial/scripts/initializedb.py | 45 +++++ .../tutorial/static/pyramid-16x16.png | Bin 0 -> 1319 bytes .../installation/tutorial/static/pyramid.png | Bin 0 -> 12901 bytes .../installation/tutorial/static/theme.css | 154 ++++++++++++++++++ .../tutorial/static/theme.min.css | 1 + .../tutorial/templates/404.jinja2 | 8 + .../tutorial/templates/layout.jinja2 | 66 ++++++++ .../tutorial/templates/mytemplate.jinja2 | 8 + .../wiki2/src/installation/tutorial/tests.py | 65 ++++++++ .../installation/tutorial/views/__init__.py | 0 .../installation/tutorial/views/default.py | 33 ++++ .../installation/tutorial/views/notfound.py | 7 + 19 files changed, 514 insertions(+) create mode 100644 docs/tutorials/wiki2/src/installation/CHANGES.txt create mode 100644 docs/tutorials/wiki2/src/installation/tutorial/__init__.py create mode 100644 docs/tutorials/wiki2/src/installation/tutorial/models/__init__.py create mode 100644 docs/tutorials/wiki2/src/installation/tutorial/models/meta.py create mode 100644 docs/tutorials/wiki2/src/installation/tutorial/models/mymodel.py create mode 100644 docs/tutorials/wiki2/src/installation/tutorial/routes.py create mode 100644 docs/tutorials/wiki2/src/installation/tutorial/scripts/__init__.py create mode 100644 docs/tutorials/wiki2/src/installation/tutorial/scripts/initializedb.py create mode 100644 docs/tutorials/wiki2/src/installation/tutorial/static/pyramid-16x16.png create mode 100644 docs/tutorials/wiki2/src/installation/tutorial/static/pyramid.png create mode 100644 docs/tutorials/wiki2/src/installation/tutorial/static/theme.css create mode 100644 docs/tutorials/wiki2/src/installation/tutorial/static/theme.min.css create mode 100644 docs/tutorials/wiki2/src/installation/tutorial/templates/404.jinja2 create mode 100644 docs/tutorials/wiki2/src/installation/tutorial/templates/layout.jinja2 create mode 100644 docs/tutorials/wiki2/src/installation/tutorial/templates/mytemplate.jinja2 create mode 100644 docs/tutorials/wiki2/src/installation/tutorial/tests.py create mode 100644 docs/tutorials/wiki2/src/installation/tutorial/views/__init__.py create mode 100644 docs/tutorials/wiki2/src/installation/tutorial/views/default.py create mode 100644 docs/tutorials/wiki2/src/installation/tutorial/views/notfound.py diff --git a/docs/tutorials/wiki2/src/installation/CHANGES.txt b/docs/tutorials/wiki2/src/installation/CHANGES.txt new file mode 100644 index 0000000000..35a34f3324 --- /dev/null +++ b/docs/tutorials/wiki2/src/installation/CHANGES.txt @@ -0,0 +1,4 @@ +0.0 +--- + +- Initial version diff --git a/docs/tutorials/wiki2/src/installation/tutorial/__init__.py b/docs/tutorials/wiki2/src/installation/tutorial/__init__.py new file mode 100644 index 0000000000..4dab448234 --- /dev/null +++ b/docs/tutorials/wiki2/src/installation/tutorial/__init__.py @@ -0,0 +1,12 @@ +from pyramid.config import Configurator + + +def main(global_config, **settings): + """ This function returns a Pyramid WSGI application. + """ + config = Configurator(settings=settings) + config.include('pyramid_jinja2') + config.include('.models') + config.include('.routes') + config.scan() + return config.make_wsgi_app() diff --git a/docs/tutorials/wiki2/src/installation/tutorial/models/__init__.py b/docs/tutorials/wiki2/src/installation/tutorial/models/__init__.py new file mode 100644 index 0000000000..48a957ecb0 --- /dev/null +++ b/docs/tutorials/wiki2/src/installation/tutorial/models/__init__.py @@ -0,0 +1,73 @@ +from sqlalchemy import engine_from_config +from sqlalchemy.orm import sessionmaker +from sqlalchemy.orm import configure_mappers +import zope.sqlalchemy + +# import or define all models here to ensure they are attached to the +# Base.metadata prior to any initialization routines +from .mymodel import MyModel # flake8: noqa + +# run configure_mappers after defining all of the models to ensure +# all relationships can be setup +configure_mappers() + + +def get_engine(settings, prefix='sqlalchemy.'): + return engine_from_config(settings, prefix) + + +def get_session_factory(engine): + factory = sessionmaker() + factory.configure(bind=engine) + return factory + + +def get_tm_session(session_factory, transaction_manager): + """ + Get a ``sqlalchemy.orm.Session`` instance backed by a transaction. + + This function will hook the session to the transaction manager which + will take care of committing any changes. + + - When using pyramid_tm it will automatically be committed or aborted + depending on whether an exception is raised. + + - When using scripts you should wrap the session in a manager yourself. + For example:: + + import transaction + + engine = get_engine(settings) + session_factory = get_session_factory(engine) + with transaction.manager: + dbsession = get_tm_session(session_factory, transaction.manager) + + """ + dbsession = session_factory() + zope.sqlalchemy.register( + dbsession, transaction_manager=transaction_manager) + return dbsession + + +def includeme(config): + """ + Initialize the model for a Pyramid app. + + Activate this setup using ``config.include('tutorial.models')``. + + """ + settings = config.get_settings() + + # use pyramid_tm to hook the transaction lifecycle to the request + config.include('pyramid_tm') + + session_factory = get_session_factory(get_engine(settings)) + config.registry['dbsession_factory'] = session_factory + + # make request.dbsession available for use in Pyramid + config.add_request_method( + # r.tm is the transaction manager used by pyramid_tm + lambda r: get_tm_session(session_factory, r.tm), + 'dbsession', + reify=True + ) diff --git a/docs/tutorials/wiki2/src/installation/tutorial/models/meta.py b/docs/tutorials/wiki2/src/installation/tutorial/models/meta.py new file mode 100644 index 0000000000..fc3e8f1dd4 --- /dev/null +++ b/docs/tutorials/wiki2/src/installation/tutorial/models/meta.py @@ -0,0 +1,16 @@ +from sqlalchemy.ext.declarative import declarative_base +from sqlalchemy.schema import MetaData + +# Recommended naming convention used by Alembic, as various different database +# providers will autogenerate vastly different names making migrations more +# difficult. See: http://alembic.readthedocs.org/en/latest/naming.html +NAMING_CONVENTION = { + "ix": 'ix_%(column_0_label)s', + "uq": "uq_%(table_name)s_%(column_0_name)s", + "ck": "ck_%(table_name)s_%(constraint_name)s", + "fk": "fk_%(table_name)s_%(column_0_name)s_%(referred_table_name)s", + "pk": "pk_%(table_name)s" +} + +metadata = MetaData(naming_convention=NAMING_CONVENTION) +Base = declarative_base(metadata=metadata) diff --git a/docs/tutorials/wiki2/src/installation/tutorial/models/mymodel.py b/docs/tutorials/wiki2/src/installation/tutorial/models/mymodel.py new file mode 100644 index 0000000000..d65a01a422 --- /dev/null +++ b/docs/tutorials/wiki2/src/installation/tutorial/models/mymodel.py @@ -0,0 +1,18 @@ +from sqlalchemy import ( + Column, + Index, + Integer, + Text, +) + +from .meta import Base + + +class MyModel(Base): + __tablename__ = 'models' + id = Column(Integer, primary_key=True) + name = Column(Text) + value = Column(Integer) + + +Index('my_index', MyModel.name, unique=True, mysql_length=255) diff --git a/docs/tutorials/wiki2/src/installation/tutorial/routes.py b/docs/tutorials/wiki2/src/installation/tutorial/routes.py new file mode 100644 index 0000000000..25504ad4dc --- /dev/null +++ b/docs/tutorials/wiki2/src/installation/tutorial/routes.py @@ -0,0 +1,3 @@ +def includeme(config): + config.add_static_view('static', 'static', cache_max_age=3600) + config.add_route('home', '/') diff --git a/docs/tutorials/wiki2/src/installation/tutorial/scripts/__init__.py b/docs/tutorials/wiki2/src/installation/tutorial/scripts/__init__.py new file mode 100644 index 0000000000..5bb534f795 --- /dev/null +++ b/docs/tutorials/wiki2/src/installation/tutorial/scripts/__init__.py @@ -0,0 +1 @@ +# package diff --git a/docs/tutorials/wiki2/src/installation/tutorial/scripts/initializedb.py b/docs/tutorials/wiki2/src/installation/tutorial/scripts/initializedb.py new file mode 100644 index 0000000000..7307ecc5c4 --- /dev/null +++ b/docs/tutorials/wiki2/src/installation/tutorial/scripts/initializedb.py @@ -0,0 +1,45 @@ +import os +import sys +import transaction + +from pyramid.paster import ( + get_appsettings, + setup_logging, + ) + +from pyramid.scripts.common import parse_vars + +from ..models.meta import Base +from ..models import ( + get_engine, + get_session_factory, + get_tm_session, + ) +from ..models import MyModel + + +def usage(argv): + cmd = os.path.basename(argv[0]) + print('usage: %s [var=value]\n' + '(example: "%s development.ini")' % (cmd, cmd)) + sys.exit(1) + + +def main(argv=sys.argv): + if len(argv) < 2: + usage(argv) + config_uri = argv[1] + options = parse_vars(argv[2:]) + setup_logging(config_uri) + settings = get_appsettings(config_uri, options=options) + + engine = get_engine(settings) + Base.metadata.create_all(engine) + + session_factory = get_session_factory(engine) + + with transaction.manager: + dbsession = get_tm_session(session_factory, transaction.manager) + + model = MyModel(name='one', value=1) + dbsession.add(model) diff --git a/docs/tutorials/wiki2/src/installation/tutorial/static/pyramid-16x16.png b/docs/tutorials/wiki2/src/installation/tutorial/static/pyramid-16x16.png new file mode 100644 index 0000000000000000000000000000000000000000..979203112e76ba4cfdb8cd6f108f4275e987d99a GIT binary patch literal 1319 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`k|nMYCBgY=CFO}lsSJ)O`AMk? zp1FzXsX?iUDV2pMQ*9U+n3Xd_B1$5BeXNr6bM+EIYV;~{3xK*A7;Nk-3KEmEQ%e+* zQqwc@Y?a>c-mj#PnPRIHZt82`Ti~3Uk?B!Ylp0*+7m{3+ootz+WN)WnQ(*-(AUCxn zQK2F?C$HG5!d3}vt`(3C64qBz04piUwpD^SD#ABF!8yMuRl!uxR5#hc&_u!9QqR!T z(8R(}N5ROz&{*HVSl`fC*U-qyz|zXlQ~?TIxIyg#@@$ndN=gc>^!3Zj z%k|2Q_413-^$jg8E%gnI^o@*kfhu&1EAvVcD|GXUm0>2hq!uR^WfqiV=I1GZOiWD5 zFD$Tv3bSNU;+l1ennz|zM-B0$V)JVzP|XC=H|jx7ncO3BHWAB;NpiyW)Z+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^> zZT8CnaH6nr&{z*|R^kiBQ+F~Xc#k)Zy@qx=9X;1owIH&e11>e87B%t5{HdoXS2-to zr#8ZScpc~&xA-Rzj|7=3lm?zNxvYzQFKs}`i7PHh*@@1f#4bY=*JAGO$B`KswU6qk z4pv|D(EcXX?%Kgk61Rp87zrFONG1qP5O2PD5;%um4G&L#&VdIksYvht7=x@A%-0}) z#M0klAu-FByr+33Z>(rhsl9r{hKy(dGIb0NO@Upvu zF|hY1SW4V1-iLMxtBVWRX{0+t#+3TzYB|i!p-tu;%KcE(?OVhTZAcDp3R2|PDiGg} zmQ!0&b4?b@50a{16wL8ddl(&o4ZNGif}F!QvwPq4tjrRx^QQg=y*}#STZ+-TgYO3N z>n8i!y?A01eJmuz7c+$#v1s_y%&Dw0zk9lwW>rQ>9Mj!Qi}%{U!*_vy4|JDp04i(n zH?m{#z{^5aANtNPZ6C!y^sYAVmnHpn$N+j6S;F=gHKtH^yZ|^Au9_5R*O_?Qj;zem zxaZs0$F~cllF440*kOy9khe)tt|^BDNJ8Tcu{-DD>$IZ_Kc|8u4!r56T3aoqK?q06 zi?@8kkW6&x!?7cg@NoQyCY%D##F^$x2} zmJs7q`ZtUjtlKHFFz4p;aWhHjF6Um@rktsn?oI1D*-Hd!(Df5N>jAUh#W*oc<&Bi7 zHo%dei>%VPt3hk6MxNi_Es7TtGMdasl<|~f(O$o~A?FarcW*)Fe*vwclnHDZ?}+SP zgYR&kn8RYb9O9><=RQuodIuwAN)ulS;SGy)PX}i^~1UYf0k$b`JnqicQgxToaq?rolg6VA7$>(o?TbE z6jEI3BBqxbUgL{6t@896dly!z7dXPugQXkT$}T@PWqm_3(f}$Agk`G%;50L{=*mi| zTE(qgB%svciozkc)B +

Pyramid Alchemy scaffold

+

404 Page Not Found

+ +{% endblock content %} diff --git a/docs/tutorials/wiki2/src/installation/tutorial/templates/layout.jinja2 b/docs/tutorials/wiki2/src/installation/tutorial/templates/layout.jinja2 new file mode 100644 index 0000000000..ab8c5ea3d0 --- /dev/null +++ b/docs/tutorials/wiki2/src/installation/tutorial/templates/layout.jinja2 @@ -0,0 +1,66 @@ + + + + + + + + + + + Alchemy Scaffold for The Pyramid Web Framework + + + + + + + + + + + + + +
+
+
+
+ +
+
+ {% block content %} +

No content

+ {% endblock content %} +
+
+
+ +
+
+ +
+
+
+ + + + + + + + diff --git a/docs/tutorials/wiki2/src/installation/tutorial/templates/mytemplate.jinja2 b/docs/tutorials/wiki2/src/installation/tutorial/templates/mytemplate.jinja2 new file mode 100644 index 0000000000..6b49869c40 --- /dev/null +++ b/docs/tutorials/wiki2/src/installation/tutorial/templates/mytemplate.jinja2 @@ -0,0 +1,8 @@ +{% extends "layout.jinja2" %} + +{% block content %} +
+

Pyramid Alchemy scaffold

+

Welcome to {{project}}, an application generated by
the Pyramid Web Framework 1.7.

+
+{% endblock content %} diff --git a/docs/tutorials/wiki2/src/installation/tutorial/tests.py b/docs/tutorials/wiki2/src/installation/tutorial/tests.py new file mode 100644 index 0000000000..99e95efd30 --- /dev/null +++ b/docs/tutorials/wiki2/src/installation/tutorial/tests.py @@ -0,0 +1,65 @@ +import unittest +import transaction + +from pyramid import testing + + +def dummy_request(dbsession): + return testing.DummyRequest(dbsession=dbsession) + + +class BaseTest(unittest.TestCase): + def setUp(self): + self.config = testing.setUp(settings={ + 'sqlalchemy.url': 'sqlite:///:memory:' + }) + self.config.include('.models') + settings = self.config.get_settings() + + from .models import ( + get_engine, + get_session_factory, + get_tm_session, + ) + + self.engine = get_engine(settings) + session_factory = get_session_factory(self.engine) + + self.session = get_tm_session(session_factory, transaction.manager) + + def init_database(self): + from .models.meta import Base + Base.metadata.create_all(self.engine) + + def tearDown(self): + from .models.meta import Base + + testing.tearDown() + transaction.abort() + Base.metadata.drop_all(self.engine) + + +class TestMyViewSuccessCondition(BaseTest): + + def setUp(self): + super(TestMyViewSuccessCondition, self).setUp() + self.init_database() + + from .models import MyModel + + model = MyModel(name='one', value=55) + self.session.add(model) + + def test_passing_view(self): + from .views.default import my_view + info = my_view(dummy_request(self.session)) + self.assertEqual(info['one'].name, 'one') + self.assertEqual(info['project'], 'tutorial') + + +class TestMyViewFailureCondition(BaseTest): + + def test_failing_view(self): + from .views.default import my_view + info = my_view(dummy_request(self.session)) + self.assertEqual(info.status_int, 500) diff --git a/docs/tutorials/wiki2/src/installation/tutorial/views/__init__.py b/docs/tutorials/wiki2/src/installation/tutorial/views/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/tutorials/wiki2/src/installation/tutorial/views/default.py b/docs/tutorials/wiki2/src/installation/tutorial/views/default.py new file mode 100644 index 0000000000..ad0c728d78 --- /dev/null +++ b/docs/tutorials/wiki2/src/installation/tutorial/views/default.py @@ -0,0 +1,33 @@ +from pyramid.response import Response +from pyramid.view import view_config + +from sqlalchemy.exc import DBAPIError + +from ..models import MyModel + + +@view_config(route_name='home', renderer='../templates/mytemplate.jinja2') +def my_view(request): + try: + query = request.dbsession.query(MyModel) + one = query.filter(MyModel.name == 'one').first() + except DBAPIError: + return Response(db_err_msg, content_type='text/plain', status=500) + return {'one': one, 'project': 'tutorial'} + + +db_err_msg = """\ +Pyramid is having a problem using your SQL database. The problem +might be caused by one of the following things: + +1. You may need to run the "initialize_tutorial_db" script + to initialize your database tables. Check your virtual + environment's "bin" directory for this script and try to run it. + +2. Your database server may not be running. Check that the + database server referred to by the "sqlalchemy.url" setting in + your "development.ini" file is running. + +After you fix the problem, please restart the Pyramid application to +try it again. +""" diff --git a/docs/tutorials/wiki2/src/installation/tutorial/views/notfound.py b/docs/tutorials/wiki2/src/installation/tutorial/views/notfound.py new file mode 100644 index 0000000000..69d6e2804e --- /dev/null +++ b/docs/tutorials/wiki2/src/installation/tutorial/views/notfound.py @@ -0,0 +1,7 @@ +from pyramid.view import notfound_view_config + + +@notfound_view_config(renderer='../templates/404.jinja2') +def notfound_view(request): + request.response.status = 404 + return {} From d8be5a579541ebf48fdb0ee613b87e06222fa9ca Mon Sep 17 00:00:00 2001 From: Steve Piercy Date: Sat, 9 Apr 2016 01:00:41 -0700 Subject: [PATCH 039/102] - use literalinclude for setup.py source - strip comments - update py.test output using recently updated scaffold from master branch - remove duplicate bullet points --- docs/tutorials/wiki2/installation.rst | 145 ++++++++------------------ 1 file changed, 42 insertions(+), 103 deletions(-) diff --git a/docs/tutorials/wiki2/installation.rst b/docs/tutorials/wiki2/installation.rst index bd52b8f7a3..a592029cd3 100644 --- a/docs/tutorials/wiki2/installation.rst +++ b/docs/tutorials/wiki2/installation.rst @@ -230,77 +230,22 @@ packages. Success executing this command will show a line like the following: Install testing requirements ---------------------------- -In order to run tests, we need to install the testing requirements, which means -we need to edit our ``setup.py``: +In order to run tests, we need to install the testing requirements. This is +done through our project's ``setup.py`` file, in the ``testing_extras`` and +``extras_requires`` stanzas, and by issuing the command below for your +operating system. -.. .. literalinclude:: src/installation/setup.py - :language: py +.. literalinclude:: src/installation/setup.py + :language: python :linenos: - :emphasize-lines: 23-30,50-52 + :lineno-start: 22 + :lines: 22-26 -.. code-block:: python +.. literalinclude:: src/installation/setup.py + :language: python :linenos: - :emphasize-lines: 22-26,46-48 - - import os - - from setuptools import setup, find_packages - - here = os.path.abspath(os.path.dirname(__file__)) - with open(os.path.join(here, 'README.txt')) as f: - README = f.read() - with open(os.path.join(here, 'CHANGES.txt')) as f: - CHANGES = f.read() - - requires = [ - 'pyramid', - 'pyramid_jinja2', - 'pyramid_debugtoolbar', - 'pyramid_tm', - 'SQLAlchemy', - 'transaction', - 'zope.sqlalchemy', - 'waitress', - ] - - testing_extras = [ - 'WebTest >= 1.3.1', # py3 compat - 'pytest', # includes virtualenv - 'pytest-cov', - ] - - setup(name='tutorial', - version='0.0', - description='tutorial', - long_description=README + '\n\n' + CHANGES, - classifiers=[ - "Programming Language :: Python", - "Framework :: Pyramid", - "Topic :: Internet :: WWW/HTTP", - "Topic :: Internet :: WWW/HTTP :: WSGI :: Application", - ], - author='', - author_email='', - url='', - keywords='web wsgi bfg pylons pyramid', - packages=find_packages(), - include_package_data=True, - zip_safe=False, - extras_require={ - 'testing': testing_extras, - }, - install_requires=requires, - entry_points="""\ - [paste.app_factory] - main = tutorial:main - [console_scripts] - initialize_tutorial_db = tutorial.scripts.initializedb:main - """, - ) - -Only the emphasized lines need to be edited. - -Next install the testing requirements. + :lineno-start: 45 + :lines: 45-47 On UNIX ^^^^^^^ @@ -332,10 +277,6 @@ On UNIX $ $VENV/bin/py.test tutorial/tests.py -q -.. TODO remove comments - -.. py.test? See https://github.com/Pylons/pyramid/issues/2104#issuecomment-155852046 - On Windows ^^^^^^^^^^ @@ -343,8 +284,6 @@ On Windows c:\pyramidtut\tutorial> %VENV%\Scripts\py.test tutorial\tests.py -q -.. py.test? See https://github.com/Pylons/pyramid/issues/2104#issuecomment-155852046 - For a successful test run, you should see output that ends like this: .. code-block:: bash @@ -393,14 +332,19 @@ If successful, you will see output something like this: ------------------ coverage: platform Python 3.5.1 ------------------ Name Stmts Miss Cover Missing ---------------------------------------------------------------- - tutorial/__init__.py 13 9 31% 13-21 - tutorial/models.py 12 0 100% + tutorial/__init__.py 8 6 25% 7-12 + tutorial/models/__init__.py 22 0 100% + tutorial/models/meta.py 5 0 100% + tutorial/models/mymodel.py 8 0 100% + tutorial/routes.py 3 3 0% 1-3 tutorial/scripts/__init__.py 0 0 100% - tutorial/scripts/initializedb.py 24 24 0% 1-40 + tutorial/scripts/initializedb.py 26 26 0% 1-45 tutorial/tests.py 39 0 100% - tutorial/views.py 11 0 100% + tutorial/views/__init__.py 0 0 100% + tutorial/views/default.py 12 0 100% + tutorial/views/notfound.py 4 4 0% 1-7 ---------------------------------------------------------------- - TOTAL 99 33 67% + TOTAL 127 39 69% ===================== 2 passed in 0.57 seconds ====================== @@ -446,15 +390,17 @@ On Windows c:\pyramidtut\tutorial> %VENV%\Scripts\initialize_tutorial_db development.ini -The output to your console should be something like this:: +The output to your console should be something like this: - 2016-02-21 23:57:41,793 INFO [sqlalchemy.engine.base.Engine:1192][MainThread] SELECT CAST('test plain returns' AS VARCHAR(60)) AS anon_1 - 2016-02-21 23:57:41,793 INFO [sqlalchemy.engine.base.Engine:1193][MainThread] () - 2016-02-21 23:57:41,794 INFO [sqlalchemy.engine.base.Engine:1192][MainThread] SELECT CAST('test unicode returns' AS VARCHAR(60)) AS anon_1 - 2016-02-21 23:57:41,794 INFO [sqlalchemy.engine.base.Engine:1193][MainThread] () - 2016-02-21 23:57:41,796 INFO [sqlalchemy.engine.base.Engine:1097][MainThread] PRAGMA table_info("models") - 2016-02-21 23:57:41,796 INFO [sqlalchemy.engine.base.Engine:1100][MainThread] () - 2016-02-21 23:57:41,798 INFO [sqlalchemy.engine.base.Engine:1097][MainThread] +.. code-block:: bash + + 2016-04-09 00:53:37,801 INFO [sqlalchemy.engine.base.Engine:1192][MainThread] SELECT CAST('test plain returns' AS VARCHAR(60)) AS anon_1 + 2016-04-09 00:53:37,801 INFO [sqlalchemy.engine.base.Engine:1193][MainThread] () + 2016-04-09 00:53:37,802 INFO [sqlalchemy.engine.base.Engine:1192][MainThread] SELECT CAST('test unicode returns' AS VARCHAR(60)) AS anon_1 + 2016-04-09 00:53:37,802 INFO [sqlalchemy.engine.base.Engine:1193][MainThread] () + 2016-04-09 00:53:37,802 INFO [sqlalchemy.engine.base.Engine:1097][MainThread] PRAGMA table_info("models") + 2016-04-09 00:53:37,803 INFO [sqlalchemy.engine.base.Engine:1100][MainThread] () + 2016-04-09 00:53:37,803 INFO [sqlalchemy.engine.base.Engine:1097][MainThread] CREATE TABLE models ( id INTEGER NOT NULL, name TEXT, @@ -463,15 +409,15 @@ The output to your console should be something like this:: ) - 2016-02-21 23:57:41,798 INFO [sqlalchemy.engine.base.Engine:1100][MainThread] () - 2016-02-21 23:57:41,798 INFO [sqlalchemy.engine.base.Engine:686][MainThread] COMMIT - 2016-02-21 23:57:41,799 INFO [sqlalchemy.engine.base.Engine:1097][MainThread] CREATE UNIQUE INDEX my_index ON models (name) - 2016-02-21 23:57:41,799 INFO [sqlalchemy.engine.base.Engine:1100][MainThread] () - 2016-02-21 23:57:41,799 INFO [sqlalchemy.engine.base.Engine:686][MainThread] COMMIT - 2016-02-21 23:57:41,801 INFO [sqlalchemy.engine.base.Engine:646][MainThread] BEGIN (implicit) - 2016-02-21 23:57:41,802 INFO [sqlalchemy.engine.base.Engine:1097][MainThread] INSERT INTO models (name, value) VALUES (?, ?) - 2016-02-21 23:57:41,802 INFO [sqlalchemy.engine.base.Engine:1100][MainThread] ('one', 1) - 2016-02-21 23:57:41,821 INFO [sqlalchemy.engine.base.Engine:686][MainThread] COMMIT + 2016-04-09 00:53:37,803 INFO [sqlalchemy.engine.base.Engine:1100][MainThread] () + 2016-04-09 00:53:37,804 INFO [sqlalchemy.engine.base.Engine:686][MainThread] COMMIT + 2016-04-09 00:53:37,805 INFO [sqlalchemy.engine.base.Engine:1097][MainThread] CREATE UNIQUE INDEX my_index ON models (name) + 2016-04-09 00:53:37,805 INFO [sqlalchemy.engine.base.Engine:1100][MainThread] () + 2016-04-09 00:53:37,806 INFO [sqlalchemy.engine.base.Engine:686][MainThread] COMMIT + 2016-04-09 00:53:37,807 INFO [sqlalchemy.engine.base.Engine:646][MainThread] BEGIN (implicit) + 2016-04-09 00:53:37,808 INFO [sqlalchemy.engine.base.Engine:1097][MainThread] INSERT INTO models (name, value) VALUES (?, ?) + 2016-04-09 00:53:37,808 INFO [sqlalchemy.engine.base.Engine:1100][MainThread] ('one', 1) + 2016-04-09 00:53:37,809 INFO [sqlalchemy.engine.base.Engine:686][MainThread] COMMIT Success! You should now have a ``tutorial.sqlite`` file in your current working directory. This is an SQLite database with a single table defined in it @@ -534,16 +480,9 @@ assumptions: - You are willing to use :term:`URL dispatch` to map URLs to code. -- You want to use zope.sqlalchemy_, pyramid_tm_ and the transaction_ package +- You want to use zope.sqlalchemy_, pyramid_tm_, and the transaction_ packages to scope sessions to requests. -- You want to use pyramid_jinja2_ to render your templates. - Different templating engines can be used but we had to choose one to - make the tutorial. See :ref:`available_template_system_bindings` for some - options. -- You want to use zope.sqlalchemy_, pyramid_tm_ and the transaction_ package to - scope sessions to requests. - - You want to use pyramid_jinja2_ to render your templates. Different templating engines can be used, but we had to choose one to make this tutorial. See :ref:`available_template_system_bindings` for some options. From 458d513ba5ffd054323be1da9306ad0d37d0c10f Mon Sep 17 00:00:00 2001 From: Steve Piercy Date: Sat, 9 Apr 2016 01:11:43 -0700 Subject: [PATCH 040/102] - add missing files --- .../wiki2/src/installation/MANIFEST.in | 2 + .../wiki2/src/installation/README.txt | 14 ++++ .../wiki2/src/installation/development.ini | 71 +++++++++++++++++++ .../wiki2/src/installation/production.ini | 60 ++++++++++++++++ .../tutorials/wiki2/src/installation/setup.py | 55 ++++++++++++++ 5 files changed, 202 insertions(+) create mode 100644 docs/tutorials/wiki2/src/installation/MANIFEST.in create mode 100644 docs/tutorials/wiki2/src/installation/README.txt create mode 100644 docs/tutorials/wiki2/src/installation/development.ini create mode 100644 docs/tutorials/wiki2/src/installation/production.ini create mode 100644 docs/tutorials/wiki2/src/installation/setup.py diff --git a/docs/tutorials/wiki2/src/installation/MANIFEST.in b/docs/tutorials/wiki2/src/installation/MANIFEST.in new file mode 100644 index 0000000000..42cd299b50 --- /dev/null +++ b/docs/tutorials/wiki2/src/installation/MANIFEST.in @@ -0,0 +1,2 @@ +include *.txt *.ini *.cfg *.rst +recursive-include tutorial *.ico *.png *.css *.gif *.jpg *.jinja2 *.pt *.txt *.mak *.mako *.js *.html *.xml diff --git a/docs/tutorials/wiki2/src/installation/README.txt b/docs/tutorials/wiki2/src/installation/README.txt new file mode 100644 index 0000000000..68f430110c --- /dev/null +++ b/docs/tutorials/wiki2/src/installation/README.txt @@ -0,0 +1,14 @@ +tutorial README +================== + +Getting Started +--------------- + +- cd + +- $VENV/bin/python setup.py develop + +- $VENV/bin/initialize_tutorial_db development.ini + +- $VENV/bin/pserve development.ini + diff --git a/docs/tutorials/wiki2/src/installation/development.ini b/docs/tutorials/wiki2/src/installation/development.ini new file mode 100644 index 0000000000..22b733e10f --- /dev/null +++ b/docs/tutorials/wiki2/src/installation/development.ini @@ -0,0 +1,71 @@ +### +# app configuration +# http://docs.pylonsproject.org/projects/pyramid/en/1.7-branch/narr/environment.html +### + +[app:main] +use = egg:tutorial + +pyramid.reload_templates = true +pyramid.debug_authorization = false +pyramid.debug_notfound = false +pyramid.debug_routematch = false +pyramid.default_locale_name = en +pyramid.includes = + pyramid_debugtoolbar + pyramid_tm + +sqlalchemy.url = sqlite:///%(here)s/tutorial.sqlite + +# By default, the toolbar only appears for clients from IP addresses +# '127.0.0.1' and '::1'. +# debugtoolbar.hosts = 127.0.0.1 ::1 + +### +# wsgi server configuration +### + +[server:main] +use = egg:waitress#main +host = 127.0.0.1 +port = 6543 + +### +# logging configuration +# http://docs.pylonsproject.org/projects/pyramid/en/1.7-branch/narr/logging.html +### + +[loggers] +keys = root, tutorial, sqlalchemy + +[handlers] +keys = console + +[formatters] +keys = generic + +[logger_root] +level = INFO +handlers = console + +[logger_tutorial] +level = DEBUG +handlers = +qualname = tutorial + +[logger_sqlalchemy] +level = INFO +handlers = +qualname = sqlalchemy.engine +# "level = INFO" logs SQL queries. +# "level = DEBUG" logs SQL queries and results. +# "level = WARN" logs neither. (Recommended for production systems.) + +[handler_console] +class = StreamHandler +args = (sys.stderr,) +level = NOTSET +formatter = generic + +[formatter_generic] +format = %(asctime)s %(levelname)-5.5s [%(name)s:%(lineno)s][%(threadName)s] %(message)s diff --git a/docs/tutorials/wiki2/src/installation/production.ini b/docs/tutorials/wiki2/src/installation/production.ini new file mode 100644 index 0000000000..d2ecfe22ab --- /dev/null +++ b/docs/tutorials/wiki2/src/installation/production.ini @@ -0,0 +1,60 @@ +### +# app configuration +# http://docs.pylonsproject.org/projects/pyramid/en/1.7-branch/narr/environment.html +### + +[app:main] +use = egg:tutorial + +pyramid.reload_templates = false +pyramid.debug_authorization = false +pyramid.debug_notfound = false +pyramid.debug_routematch = false +pyramid.default_locale_name = en + +sqlalchemy.url = sqlite:///%(here)s/tutorial.sqlite + +[server:main] +use = egg:waitress#main +host = 0.0.0.0 +port = 6543 + +### +# logging configuration +# http://docs.pylonsproject.org/projects/pyramid/en/1.7-branch/narr/logging.html +### + +[loggers] +keys = root, tutorial, sqlalchemy + +[handlers] +keys = console + +[formatters] +keys = generic + +[logger_root] +level = WARN +handlers = console + +[logger_tutorial] +level = WARN +handlers = +qualname = tutorial + +[logger_sqlalchemy] +level = WARN +handlers = +qualname = sqlalchemy.engine +# "level = INFO" logs SQL queries. +# "level = DEBUG" logs SQL queries and results. +# "level = WARN" logs neither. (Recommended for production systems.) + +[handler_console] +class = StreamHandler +args = (sys.stderr,) +level = NOTSET +formatter = generic + +[formatter_generic] +format = %(asctime)s %(levelname)-5.5s [%(name)s:%(lineno)s][%(threadName)s] %(message)s diff --git a/docs/tutorials/wiki2/src/installation/setup.py b/docs/tutorials/wiki2/src/installation/setup.py new file mode 100644 index 0000000000..c82c880c91 --- /dev/null +++ b/docs/tutorials/wiki2/src/installation/setup.py @@ -0,0 +1,55 @@ +import os + +from setuptools import setup, find_packages + +here = os.path.abspath(os.path.dirname(__file__)) +with open(os.path.join(here, 'README.txt')) as f: + README = f.read() +with open(os.path.join(here, 'CHANGES.txt')) as f: + CHANGES = f.read() + +requires = [ + 'pyramid', + 'pyramid_jinja2', + 'pyramid_debugtoolbar', + 'pyramid_tm', + 'SQLAlchemy', + 'transaction', + 'zope.sqlalchemy', + 'waitress', + ] + +testing_extras = [ + 'WebTest >= 1.3.1', # py3 compat + 'pytest', # includes virtualenv + 'pytest-cov', + ] + +setup(name='tutorial', + version='0.0', + description='tutorial', + long_description=README + '\n\n' + CHANGES, + classifiers=[ + "Programming Language :: Python", + "Framework :: Pyramid", + "Topic :: Internet :: WWW/HTTP", + "Topic :: Internet :: WWW/HTTP :: WSGI :: Application", + ], + author='', + author_email='', + url='', + keywords='web wsgi bfg pylons pyramid', + packages=find_packages(), + include_package_data=True, + zip_safe=False, + extras_require={ + 'testing': testing_extras, + }, + install_requires=requires, + entry_points="""\ + [paste.app_factory] + main = tutorial:main + [console_scripts] + initialize_tutorial_db = tutorial.scripts.initializedb:main + """, + ) From b93b011f1a4904963f453c2583f4c0d3aa50ffe5 Mon Sep 17 00:00:00 2001 From: Steve Piercy Date: Sat, 9 Apr 2016 02:10:54 -0700 Subject: [PATCH 041/102] - update wiki2/src/basiclayout files --- .../wiki2/src/basiclayout/development.ini | 4 ++-- .../wiki2/src/basiclayout/production.ini | 4 ++-- docs/tutorials/wiki2/src/basiclayout/setup.py | 23 +++++++++++-------- .../tutorial/templates/layout.jinja2 | 2 +- .../tutorial/templates/mytemplate.jinja2 | 2 +- .../wiki2/src/basiclayout/tutorial/tests.py | 2 +- 6 files changed, 20 insertions(+), 17 deletions(-) diff --git a/docs/tutorials/wiki2/src/basiclayout/development.ini b/docs/tutorials/wiki2/src/basiclayout/development.ini index 99c4ff0fe2..22b733e10f 100644 --- a/docs/tutorials/wiki2/src/basiclayout/development.ini +++ b/docs/tutorials/wiki2/src/basiclayout/development.ini @@ -1,6 +1,6 @@ ### # app configuration -# http://docs.pylonsproject.org/projects/pyramid/en/latest/narr/environment.html +# http://docs.pylonsproject.org/projects/pyramid/en/1.7-branch/narr/environment.html ### [app:main] @@ -32,7 +32,7 @@ port = 6543 ### # logging configuration -# http://docs.pylonsproject.org/projects/pyramid/en/latest/narr/logging.html +# http://docs.pylonsproject.org/projects/pyramid/en/1.7-branch/narr/logging.html ### [loggers] diff --git a/docs/tutorials/wiki2/src/basiclayout/production.ini b/docs/tutorials/wiki2/src/basiclayout/production.ini index cb1db32114..d2ecfe22ab 100644 --- a/docs/tutorials/wiki2/src/basiclayout/production.ini +++ b/docs/tutorials/wiki2/src/basiclayout/production.ini @@ -1,6 +1,6 @@ ### # app configuration -# http://docs.pylonsproject.org/projects/pyramid/en/latest/narr/environment.html +# http://docs.pylonsproject.org/projects/pyramid/en/1.7-branch/narr/environment.html ### [app:main] @@ -21,7 +21,7 @@ port = 6543 ### # logging configuration -# http://docs.pylonsproject.org/projects/pyramid/en/latest/narr/logging.html +# http://docs.pylonsproject.org/projects/pyramid/en/1.7-branch/narr/logging.html ### [loggers] diff --git a/docs/tutorials/wiki2/src/basiclayout/setup.py b/docs/tutorials/wiki2/src/basiclayout/setup.py index 7bc6977301..c82c880c91 100644 --- a/docs/tutorials/wiki2/src/basiclayout/setup.py +++ b/docs/tutorials/wiki2/src/basiclayout/setup.py @@ -19,20 +19,22 @@ 'waitress', ] -tests_require = [ - 'WebTest', -] +testing_extras = [ + 'WebTest >= 1.3.1', # py3 compat + 'pytest', # includes virtualenv + 'pytest-cov', + ] setup(name='tutorial', version='0.0', description='tutorial', long_description=README + '\n\n' + CHANGES, classifiers=[ - "Programming Language :: Python", - "Framework :: Pyramid", - "Topic :: Internet :: WWW/HTTP", - "Topic :: Internet :: WWW/HTTP :: WSGI :: Application", - ], + "Programming Language :: Python", + "Framework :: Pyramid", + "Topic :: Internet :: WWW/HTTP", + "Topic :: Internet :: WWW/HTTP :: WSGI :: Application", + ], author='', author_email='', url='', @@ -40,8 +42,9 @@ packages=find_packages(), include_package_data=True, zip_safe=False, - test_suite='tutorial', - tests_require=tests_require, + extras_require={ + 'testing': testing_extras, + }, install_requires=requires, entry_points="""\ [paste.app_factory] diff --git a/docs/tutorials/wiki2/src/basiclayout/tutorial/templates/layout.jinja2 b/docs/tutorials/wiki2/src/basiclayout/tutorial/templates/layout.jinja2 index ff624c65b5..ab8c5ea3d0 100644 --- a/docs/tutorials/wiki2/src/basiclayout/tutorial/templates/layout.jinja2 +++ b/docs/tutorials/wiki2/src/basiclayout/tutorial/templates/layout.jinja2 @@ -40,7 +40,7 @@