| | |
| | | |
| | | .. code-block:: bash |
| | | |
| | | $ cookiecutter gh:Pylons/pyramid-cookiecutter-starter --checkout master |
| | | cookiecutter gh:Pylons/pyramid-cookiecutter-starter --checkout master |
| | | |
| | | If prompted for the first item, accept the default ``yes`` by hitting return. |
| | | |
| | |
| | | .. code-block:: bash |
| | | |
| | | # Reset our environment variable for a new virtual environment. |
| | | $ export VENV=~/env/myproject/env |
| | | export VENV=~/env/myproject/env |
| | | # Change directory into your newly created project. |
| | | $ cd myproject |
| | | cd myproject |
| | | # Create a new virtual environment... |
| | | $ python3 -m venv $VENV |
| | | python3 -m venv $VENV |
| | | # ...where we upgrade packaging tools. |
| | | $ env/bin/pip install --upgrade pip setuptools |
| | | env/bin/pip install --upgrade pip setuptools |
| | | |
| | | Or on Windows: |
| | | |
| | | .. code-block:: doscon |
| | | |
| | | # Reset our environment variable for a new virtual environment. |
| | | c:\> set VENV=c:\env\myproject\env |
| | | set VENV=c:\env\myproject\env |
| | | # Change directory into your newly created project. |
| | | c:\> cd myproject |
| | | cd myproject |
| | | # Create a new virtual environment... |
| | | c:\myproject> python -m venv %VENV% |
| | | python -m venv %VENV% |
| | | # ...where we upgrade packaging tools. |
| | | c:\myproject> %VENV%\Scripts\pip install --upgrade pip setuptools |
| | | %VENV%\Scripts\pip install --upgrade pip setuptools |
| | | |
| | | As a result of invoking the ``cookiecutter`` command, a directory named |
| | | ``myproject`` is created. That directory is a :term:`project` directory. The |
| | |
| | | |
| | | .. code-block:: bash |
| | | |
| | | $ $VENV/bin/pip install -e . |
| | | $VENV/bin/pip install -e . |
| | | |
| | | Or on Windows: |
| | | |
| | | .. code-block:: doscon |
| | | |
| | | c:\env\myproject> %VENV%\Scripts\pip install -e . |
| | | %VENV%\Scripts\pip install -e . |
| | | |
| | | Elided output from a run of this command on UNIX is shown below: |
| | | |
| | | .. code-block:: bash |
| | | |
| | | Running setup.py develop for myproject |
| | | Running setup.py develop for myproject |
| | | Successfully installed Jinja2-2.8 Mako-1.0.6 MarkupSafe-0.23 \ |
| | | PasteDeploy-1.5.2 Pygments-2.1.3 WebOb-1.7.0 myproject pyramid-1.7.3 \ |
| | | pyramid-debugtoolbar-3.0.5 pyramid-jinja2-2.7 pyramid-mako-1.0.2 \ |
| | |
| | | |
| | | .. code-block:: bash |
| | | |
| | | $ $VENV/bin/pip install -e ".[testing]" |
| | | $VENV/bin/pip install -e ".[testing]" |
| | | |
| | | On Windows: |
| | | |
| | | .. code-block:: doscon |
| | | |
| | | c:\env\myproject> %VENV%\Scripts\pip install -e ".[testing]" |
| | | %VENV%\Scripts\pip install -e ".[testing]" |
| | | |
| | | Once the testing requirements are installed, then you can run the tests using |
| | | the ``py.test`` command that was just installed in the ``bin`` directory of |
| | |
| | | |
| | | .. code-block:: bash |
| | | |
| | | $ $VENV/bin/py.test -q |
| | | $VENV/bin/py.test -q |
| | | |
| | | On Windows: |
| | | |
| | | .. code-block:: doscon |
| | | |
| | | c:\env\myproject> %VENV%\Scripts\py.test -q |
| | | %VENV%\Scripts\py.test -q |
| | | |
| | | Here's sample output from a test run on UNIX: |
| | | |
| | | .. code-block:: bash |
| | | |
| | | $ $VENV/bin/py.test -q |
| | | .. |
| | | 2 passed in 0.47 seconds |
| | | $VENV/bin/py.test -q |
| | | .. |
| | | 2 passed in 0.47 seconds |
| | | |
| | | The tests themselves are found in the ``tests.py`` module in your ``cookiecutter``-generated project. Within a project generated by the ``pyramid-cookiecutter-starter`` cookiecutter, only two sample tests exist. |
| | | |
| | |
| | | |
| | | .. code-block:: bash |
| | | |
| | | $ $VENV/bin/py.test --cov -q |
| | | $VENV/bin/py.test --cov -q |
| | | |
| | | Cookiecutters include configuration defaults for ``py.test`` and test coverage. |
| | | These configuration files are ``pytest.ini`` and ``.coveragerc``, located at |
| | |
| | | |
| | | .. code-block:: bash |
| | | |
| | | $ $VENV/bin/py.test --cov=myproject myproject/tests.py -q |
| | | $VENV/bin/py.test --cov=myproject myproject/tests.py -q |
| | | |
| | | .. seealso:: See py.test's documentation for :ref:`pytest:usage` or invoke |
| | | ``py.test -h`` to see its full set of options. |
| | |
| | | |
| | | .. code-block:: bash |
| | | |
| | | $ $VENV/bin/pserve development.ini |
| | | $VENV/bin/pserve development.ini |
| | | |
| | | On Windows: |
| | | |
| | | .. code-block:: doscon |
| | | |
| | | c:\env\myproject> %VENV%\Scripts\pserve development.ini |
| | | %VENV%\Scripts\pserve development.ini |
| | | |
| | | Here's sample output from a run of ``pserve`` on UNIX: |
| | | |
| | | .. code-block:: bash |
| | | |
| | | $ $VENV/bin/pserve development.ini |
| | | Starting server in PID 77171. |
| | | Serving on http://localhost:6543 |
| | | Serving on http://localhost:6543 |
| | | $VENV/bin/pserve development.ini |
| | | Starting server in PID 77171. |
| | | Serving on http://localhost:6543 |
| | | Serving on http://localhost:6543 |
| | | |
| | | Access is restricted such that only a browser running on the same machine as |
| | | Pyramid will be able to access your Pyramid application. However, if you want |
| | |
| | | |
| | | .. code-block:: ini |
| | | |
| | | [server:main] |
| | | use = egg:waitress#main |
| | | listen = *:6543 |
| | | [server:main] |
| | | use = egg:waitress#main |
| | | listen = *:6543 |
| | | |
| | | Now when you use ``pserve`` to start the application, it will respond to |
| | | requests on *all* IP addresses possessed by your system, not just requests to |
| | |
| | | |
| | | .. code-block:: text |
| | | |
| | | $ $VENV/bin/pserve development.ini --reload |
| | | Starting subprocess with file monitor |
| | | Starting server in PID 16601. |
| | | Serving on http://localhost:6543 |
| | | Serving on http://localhost:6543 |
| | | $VENV/bin/pserve development.ini --reload |
| | | Starting subprocess with file monitor |
| | | Starting server in PID 16601. |
| | | Serving on http://localhost:6543 |
| | | Serving on http://localhost:6543 |
| | | |
| | | Now if you make a change to any of your project's ``.py`` files or ``.ini`` |
| | | files, you'll see the server restart automatically: |
| | | |
| | | .. code-block:: text |
| | | |
| | | development.ini changed; reloading... |
| | | -------------------- Restarting -------------------- |
| | | Starting server in PID 16602. |
| | | Serving on http://localhost:6543 |
| | | Serving on http://localhost:6543 |
| | | development.ini changed; reloading... |
| | | -------------------- Restarting -------------------- |
| | | Starting server in PID 16602. |
| | | Serving on http://localhost:6543 |
| | | Serving on http://localhost:6543 |
| | | |
| | | Changes to template files (such as ``.pt`` or ``.mak`` files) won't cause the |
| | | server to restart. Changes to template files don't require a server restart as |
| | |
| | | |
| | | .. code-block:: ini |
| | | |
| | | [app:main] |
| | | # .. other settings ... |
| | | debugtoolbar.hosts = 192.168.1.1 |
| | | [app:main] |
| | | # .. other settings ... |
| | | debugtoolbar.hosts = 192.168.1.1 |
| | | |
| | | For more information about what the debug toolbar allows you to do, see the |
| | | :ref:`documentation for pyramid_debugtoolbar <toolbar:overview>`. |
| | |
| | | commenting out a line. For example, instead of: |
| | | |
| | | .. code-block:: ini |
| | | :linenos: |
| | | :linenos: |
| | | |
| | | [app:main] |
| | | # ... elided configuration |
| | | pyramid.includes = |
| | | pyramid_debugtoolbar |
| | | [app:main] |
| | | # ... elided configuration |
| | | pyramid.includes = |
| | | pyramid_debugtoolbar |
| | | |
| | | Put a hash mark at the beginning of the ``pyramid_debugtoolbar`` line: |
| | | |
| | | .. code-block:: ini |
| | | :linenos: |
| | | :linenos: |
| | | |
| | | [app:main] |
| | | # ... elided configuration |
| | | pyramid.includes = |
| | | # pyramid_debugtoolbar |
| | | [app:main] |
| | | # ... elided configuration |
| | | pyramid.includes = |
| | | # pyramid_debugtoolbar |
| | | |
| | | Then restart the application to see that the toolbar has been turned off. |
| | | |
| | |
| | | |
| | | .. code-block:: text |
| | | |
| | | ImportError: No module named #pyramid_debugtoolbar |
| | | ImportError: No module named #pyramid_debugtoolbar |
| | | |
| | | .. index:: |
| | | single: project structure |
| | |
| | | |
| | | .. code-block:: text |
| | | |
| | | myproject/ |
| | | ├── .coveragerc |
| | | ├── CHANGES.txt |
| | | ├── MANIFEST.in |
| | | ├── myproject |
| | | │ ├── __init__.py |
| | | │ ├── static |
| | | │ │ ├── pyramid-16x16.png |
| | | │ │ ├── pyramid.png |
| | | │ │ └── theme.css |
| | | │ ├── templates |
| | | │ │ ├── layout.jinja2 |
| | | │ │ └── mytemplate.jinja2 |
| | | │ ├── tests.py |
| | | │ └── views.py |
| | | ├── README.txt |
| | | ├── development.ini |
| | | ├── production.ini |
| | | ├── pytest.ini |
| | | └── setup.py |
| | | myproject/ |
| | | ├── .coveragerc |
| | | ├── CHANGES.txt |
| | | ├── MANIFEST.in |
| | | ├── myproject |
| | | │ ├── __init__.py |
| | | │ ├── static |
| | | │ │ ├── pyramid-16x16.png |
| | | │ │ ├── pyramid.png |
| | | │ │ └── theme.css |
| | | │ ├── templates |
| | | │ │ ├── layout.jinja2 |
| | | │ │ └── mytemplate.jinja2 |
| | | │ ├── tests.py |
| | | │ └── views.py |
| | | ├── README.txt |
| | | ├── development.ini |
| | | ├── production.ini |
| | | ├── pytest.ini |
| | | └── setup.py |
| | | |
| | | |
| | | The ``myproject`` :term:`Project` |
| | |
| | | |
| | | .. code-block:: text |
| | | |
| | | $ $VENV/bin/python setup.py sdist |
| | | $VENV/bin/python setup.py sdist |
| | | |
| | | This will create a tarball of your application in a ``dist`` subdirectory named |
| | | ``myproject-0.0.tar.gz``. You can send this tarball to other people who want |