summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorSteve Piercy <web@stevepiercy.com>2016-12-27 02:36:30 -0800
committerSteve Piercy <web@stevepiercy.com>2016-12-27 02:36:30 -0800
commite1b26edbb88ab51b1043ef82f093507d987cc2a4 (patch)
tree9cedc3b1e3d2eb33f7946273b0360a42ccfc8a23 /docs
parente2cda93d7422de50d014bcbacc2f4c31b95508bd (diff)
downloadpyramid-e1b26edbb88ab51b1043ef82f093507d987cc2a4.tar.gz
pyramid-e1b26edbb88ab51b1043ef82f093507d987cc2a4.tar.bz2
pyramid-e1b26edbb88ab51b1043ef82f093507d987cc2a4.zip
narr/project - update for cookiecutters
- update source files - update project.png - fix literalinclude reference in logging
Diffstat (limited to 'docs')
-rw-r--r--docs/narr/MyProject/CHANGES.txt4
-rw-r--r--docs/narr/MyProject/README.txt12
-rw-r--r--docs/narr/MyProject/setup.py49
-rw-r--r--docs/narr/logging.rst2
-rw-r--r--docs/narr/myproject/.coveragerc3
-rw-r--r--docs/narr/myproject/CHANGES.txt4
-rw-r--r--docs/narr/myproject/MANIFEST.in (renamed from docs/narr/MyProject/MANIFEST.in)2
-rw-r--r--docs/narr/myproject/README.txt29
-rw-r--r--docs/narr/myproject/development.ini (renamed from docs/narr/MyProject/development.ini)6
-rw-r--r--docs/narr/myproject/myproject/__init__.py (renamed from docs/narr/MyProject/myproject/__init__.py)2
-rw-r--r--docs/narr/myproject/myproject/static/pyramid-16x16.png (renamed from docs/narr/MyProject/myproject/static/pyramid-16x16.png)bin1319 -> 1319 bytes
-rw-r--r--docs/narr/myproject/myproject/static/pyramid.png (renamed from docs/narr/MyProject/myproject/static/pyramid.png)bin12901 -> 12901 bytes
-rw-r--r--docs/narr/myproject/myproject/static/theme.css (renamed from docs/narr/MyProject/myproject/static/theme.css)8
-rw-r--r--docs/narr/myproject/myproject/templates/layout.jinja2 (renamed from docs/narr/MyProject/myproject/templates/mytemplate.pt)21
-rw-r--r--docs/narr/myproject/myproject/templates/mytemplate.jinja28
-rw-r--r--docs/narr/myproject/myproject/tests.py (renamed from docs/narr/MyProject/myproject/tests.py)0
-rw-r--r--docs/narr/myproject/myproject/views.py (renamed from docs/narr/MyProject/myproject/views.py)2
-rw-r--r--docs/narr/myproject/production.ini (renamed from docs/narr/MyProject/production.ini)6
-rw-r--r--docs/narr/myproject/pytest.ini3
-rw-r--r--docs/narr/myproject/setup.py51
-rw-r--r--docs/narr/project.pngbin133242 -> 98989 bytes
-rw-r--r--docs/narr/project.rst322
22 files changed, 308 insertions, 226 deletions
diff --git a/docs/narr/MyProject/CHANGES.txt b/docs/narr/MyProject/CHANGES.txt
deleted file mode 100644
index 35a34f332..000000000
--- a/docs/narr/MyProject/CHANGES.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-0.0
----
-
-- Initial version
diff --git a/docs/narr/MyProject/README.txt b/docs/narr/MyProject/README.txt
deleted file mode 100644
index 70759eba1..000000000
--- a/docs/narr/MyProject/README.txt
+++ /dev/null
@@ -1,12 +0,0 @@
-MyProject README
-==================
-
-Getting Started
----------------
-
-- cd <directory containing this file>
-
-- $VENV/bin/pip install -e .
-
-- $VENV/bin/pserve development.ini
-
diff --git a/docs/narr/MyProject/setup.py b/docs/narr/MyProject/setup.py
deleted file mode 100644
index a911eff6d..000000000
--- a/docs/narr/MyProject/setup.py
+++ /dev/null
@@ -1,49 +0,0 @@
-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_chameleon',
- 'pyramid_debugtoolbar',
- 'waitress',
- ]
-
-tests_require = [
- 'WebTest >= 1.3.1', # py3 compat
- 'pytest', # includes virtualenv
- 'pytest-cov',
- ]
-
-setup(name='MyProject',
- version='0.0',
- description='MyProject',
- 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 pyramid pylons',
- packages=find_packages(),
- include_package_data=True,
- zip_safe=False,
- extras_require={
- 'testing': tests_require,
- },
- install_requires=requires,
- entry_points="""\
- [paste.app_factory]
- main = myproject:main
- """,
- )
diff --git a/docs/narr/logging.rst b/docs/narr/logging.rst
index f2c990861..ec3590e62 100644
--- a/docs/narr/logging.rst
+++ b/docs/narr/logging.rst
@@ -50,7 +50,7 @@ Default logging configuration is provided in both the default
``development.ini`` and the ``production.ini`` files. If you use ``pyramid-cookiecutter-starter`` to generate a Pyramid project with the name of the package as ``hello_world``, then the logging configuration
in the ``development.ini`` file is as follows:
-.. literalinclude:: ../quick_tour/package/development.ini
+.. literalinclude:: MyProject/development.ini
:language: ini
:lineno-match:
:lines: 29-
diff --git a/docs/narr/myproject/.coveragerc b/docs/narr/myproject/.coveragerc
new file mode 100644
index 000000000..f0c31d6d7
--- /dev/null
+++ b/docs/narr/myproject/.coveragerc
@@ -0,0 +1,3 @@
+[run]
+source = myproject
+omit = myproject/test*
diff --git a/docs/narr/myproject/CHANGES.txt b/docs/narr/myproject/CHANGES.txt
new file mode 100644
index 000000000..14b902fd1
--- /dev/null
+++ b/docs/narr/myproject/CHANGES.txt
@@ -0,0 +1,4 @@
+0.0
+---
+
+- Initial version.
diff --git a/docs/narr/MyProject/MANIFEST.in b/docs/narr/myproject/MANIFEST.in
index fa1692163..1c24b8c0c 100644
--- a/docs/narr/MyProject/MANIFEST.in
+++ b/docs/narr/myproject/MANIFEST.in
@@ -1,2 +1,2 @@
include *.txt *.ini *.cfg *.rst
-recursive-include myproject *.ico *.png *.css *.gif *.jpg *.pt *.txt *.mak *.mako *.js *.html *.xml
+recursive-include myproject *.ico *.png *.css *.gif *.jpg *.pt *.txt *.mak *.mako *.js *.html *.xml *.jinja2
diff --git a/docs/narr/myproject/README.txt b/docs/narr/myproject/README.txt
new file mode 100644
index 000000000..41ef0ff91
--- /dev/null
+++ b/docs/narr/myproject/README.txt
@@ -0,0 +1,29 @@
+MyProject
+===============================
+
+Getting Started
+---------------
+
+- Change directory into your newly created project.
+
+ cd MyProject
+
+- Create a Python virtual environment.
+
+ python3 -m venv env
+
+- Upgrade packaging tools.
+
+ env/bin/pip install --upgrade pip setuptools
+
+- Install the project in editable mode with its testing requirements.
+
+ env/bin/pip install -e ".[testing]"
+
+- Run your project's tests.
+
+ env/bin/pytest
+
+- Run your project.
+
+ env/bin/pserve development.ini
diff --git a/docs/narr/MyProject/development.ini b/docs/narr/myproject/development.ini
index 3a83dcfac..5d110805a 100644
--- a/docs/narr/MyProject/development.ini
+++ b/docs/narr/myproject/development.ini
@@ -1,10 +1,10 @@
###
# app configuration
-# http://docs.pylonsproject.org/projects/pyramid/en/1.7-branch/narr/environment.html
+# http://docs.pylonsproject.org/projects/pyramid/en/latest/narr/environment.html
###
[app:main]
-use = egg:MyProject
+use = egg:myproject
pyramid.reload_templates = true
pyramid.debug_authorization = false
@@ -28,7 +28,7 @@ listen = 127.0.0.1:6543 [::1]:6543
###
# logging configuration
-# http://docs.pylonsproject.org/projects/pyramid/en/1.7-branch/narr/logging.html
+# http://docs.pylonsproject.org/projects/pyramid/en/latest/narr/logging.html
###
[loggers]
diff --git a/docs/narr/MyProject/myproject/__init__.py b/docs/narr/myproject/myproject/__init__.py
index ad5ecbc6f..49dde36d4 100644
--- a/docs/narr/MyProject/myproject/__init__.py
+++ b/docs/narr/myproject/myproject/__init__.py
@@ -5,7 +5,7 @@ def main(global_config, **settings):
""" This function returns a Pyramid WSGI application.
"""
config = Configurator(settings=settings)
- config.include('pyramid_chameleon')
+ config.include('pyramid_jinja2')
config.add_static_view('static', 'static', cache_max_age=3600)
config.add_route('home', '/')
config.scan()
diff --git a/docs/narr/MyProject/myproject/static/pyramid-16x16.png b/docs/narr/myproject/myproject/static/pyramid-16x16.png
index 979203112..979203112 100644
--- a/docs/narr/MyProject/myproject/static/pyramid-16x16.png
+++ b/docs/narr/myproject/myproject/static/pyramid-16x16.png
Binary files differ
diff --git a/docs/narr/MyProject/myproject/static/pyramid.png b/docs/narr/myproject/myproject/static/pyramid.png
index 4ab837be9..4ab837be9 100644
--- a/docs/narr/MyProject/myproject/static/pyramid.png
+++ b/docs/narr/myproject/myproject/static/pyramid.png
Binary files differ
diff --git a/docs/narr/MyProject/myproject/static/theme.css b/docs/narr/myproject/myproject/static/theme.css
index be50ad420..0f4b1a4d4 100644
--- a/docs/narr/MyProject/myproject/static/theme.css
+++ b/docs/narr/myproject/myproject/static/theme.css
@@ -72,10 +72,12 @@ p {
color: #f2b7bd;
font-weight: 400;
}
-.starter-template .links ul li a {
- color: #ffffff;
+.starter-template .links ul li a, a {
+ color: #f2b7bd;
+ text-decoration: underline;
}
-.starter-template .links ul li a:hover {
+.starter-template .links ul li a:hover, a:hover {
+ color: #ffffff;
text-decoration: underline;
}
.starter-template .links ul li .icon-muted {
diff --git a/docs/narr/MyProject/myproject/templates/mytemplate.pt b/docs/narr/myproject/myproject/templates/layout.jinja2
index 543663fe8..bfac9e64e 100644
--- a/docs/narr/MyProject/myproject/templates/mytemplate.pt
+++ b/docs/narr/myproject/myproject/templates/layout.jinja2
@@ -1,20 +1,20 @@
<!DOCTYPE html>
-<html lang="${request.locale_name}">
+<html lang="{{request.locale_name}}">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="pyramid web application">
<meta name="author" content="Pylons Project">
- <link rel="shortcut icon" href="${request.static_url('myproject:static/pyramid-16x16.png')}">
+ <link rel="shortcut icon" href="{{request.static_url('myproject:static/pyramid-16x16.png')}}">
- <title>Starter Scaffold for The Pyramid Web Framework</title>
+ <title>Cookiecutter Starter project for the Pyramid Web Framework</title>
<!-- Bootstrap core CSS -->
<link href="//oss.maxcdn.com/libs/twitter-bootstrap/3.0.3/css/bootstrap.min.css" rel="stylesheet">
<!-- Custom styles for this scaffold -->
- <link href="${request.static_url('myproject:static/theme.css')}" rel="stylesheet">
+ <link href="{{request.static_url('myproject:static/theme.css')}}" rel="stylesheet">
<!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
@@ -29,22 +29,19 @@
<div class="container">
<div class="row">
<div class="col-md-2">
- <img class="logo img-responsive" src="${request.static_url('myproject:static/pyramid.png')}" alt="pyramid web framework">
+ <img class="logo img-responsive" src="{{request.static_url('myproject:static/pyramid.png') }}" alt="pyramid web framework">
</div>
<div class="col-md-10">
- <div class="content">
- <h1><span class="font-semi-bold">Pyramid</span> <span class="smaller">Starter scaffold</span></h1>
- <p class="lead">Welcome to <span class="font-normal">${project}</span>, an&nbsp;application generated&nbsp;by<br>the <span class="font-normal">Pyramid Web Framework 1.7</span>.</p>
- </div>
+ {% block content %}
+ <p>No content</p>
+ {% endblock content %}
</div>
</div>
<div class="row">
<div class="links">
<ul>
- <li class="current-version">Generated by v1.7</li>
- <li><i class="glyphicon glyphicon-bookmark icon-muted"></i><a href="http://docs.pylonsproject.org/projects/pyramid/en/1.7-branch/">Docs</a></li>
<li><i class="glyphicon glyphicon-cog icon-muted"></i><a href="https://github.com/Pylons/pyramid">Github Project</a></li>
- <li><i class="glyphicon glyphicon-globe icon-muted"></i><a href="irc://irc.freenode.net#pyramid">IRC Channel</a></li>
+ <li><i class="glyphicon glyphicon-globe icon-muted"></i><a href="https://webchat.freenode.net/?channels=pyramid">IRC Channel</a></li>
<li><i class="glyphicon glyphicon-home icon-muted"></i><a href="http://pylonsproject.org">Pylons Project</a></li>
</ul>
</div>
diff --git a/docs/narr/myproject/myproject/templates/mytemplate.jinja2 b/docs/narr/myproject/myproject/templates/mytemplate.jinja2
new file mode 100644
index 000000000..ce042215d
--- /dev/null
+++ b/docs/narr/myproject/myproject/templates/mytemplate.jinja2
@@ -0,0 +1,8 @@
+{% extends "layout.jinja2" %}
+
+{% block content %}
+<div class="content">
+ <h1><span class="font-semi-bold">Pyramid</span> <span class="smaller">Starter project</span></h1>
+ <p class="lead">Welcome to <span class="font-normal">MyProject</span>, a&nbsp;Pyramid application generated&nbsp;by<br><span class="font-normal">Cookiecutter</span>.</p>
+</div>
+{% endblock content %}
diff --git a/docs/narr/MyProject/myproject/tests.py b/docs/narr/myproject/myproject/tests.py
index fd414cced..fd414cced 100644
--- a/docs/narr/MyProject/myproject/tests.py
+++ b/docs/narr/myproject/myproject/tests.py
diff --git a/docs/narr/MyProject/myproject/views.py b/docs/narr/myproject/myproject/views.py
index c383c5716..9e9ec4320 100644
--- a/docs/narr/MyProject/myproject/views.py
+++ b/docs/narr/myproject/myproject/views.py
@@ -1,6 +1,6 @@
from pyramid.view import view_config
-@view_config(route_name='home', renderer='templates/mytemplate.pt')
+@view_config(route_name='home', renderer='templates/mytemplate.jinja2')
def my_view(request):
return {'project': 'MyProject'}
diff --git a/docs/narr/MyProject/production.ini b/docs/narr/myproject/production.ini
index c48ca6d9b..13be488e7 100644
--- a/docs/narr/MyProject/production.ini
+++ b/docs/narr/myproject/production.ini
@@ -1,10 +1,10 @@
###
# app configuration
-# http://docs.pylonsproject.org/projects/pyramid/en/1.7-branch/narr/environment.html
+# http://docs.pylonsproject.org/projects/pyramid/en/latest/narr/environment.html
###
[app:main]
-use = egg:MyProject
+use = egg:myproject
pyramid.reload_templates = false
pyramid.debug_authorization = false
@@ -22,7 +22,7 @@ listen = *:6543
###
# logging configuration
-# http://docs.pylonsproject.org/projects/pyramid/en/1.7-branch/narr/logging.html
+# http://docs.pylonsproject.org/projects/pyramid/en/latest/narr/logging.html
###
[loggers]
diff --git a/docs/narr/myproject/pytest.ini b/docs/narr/myproject/pytest.ini
new file mode 100644
index 000000000..b1b5f4c38
--- /dev/null
+++ b/docs/narr/myproject/pytest.ini
@@ -0,0 +1,3 @@
+[pytest]
+testpaths = myproject
+python_files = *.py
diff --git a/docs/narr/myproject/setup.py b/docs/narr/myproject/setup.py
new file mode 100644
index 000000000..00e377349
--- /dev/null
+++ b/docs/narr/myproject/setup.py
@@ -0,0 +1,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',
+ 'waitress',
+]
+
+tests_require = [
+ 'WebTest >= 1.3.1', # py3 compat
+ 'pytest',
+ 'pytest-cov',
+]
+
+setup(
+ name='myproject',
+ version='0.0',
+ description='MyProject',
+ 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 pyramid pylons',
+ packages=find_packages(),
+ include_package_data=True,
+ zip_safe=False,
+ extras_require={
+ 'testing': tests_require,
+ },
+ install_requires=requires,
+ entry_points={
+ 'paste.app_factory': [
+ 'main = myproject:main',
+ ],
+ },
+)
diff --git a/docs/narr/project.png b/docs/narr/project.png
index e1afd97d4..0e17e57ab 100644
--- a/docs/narr/project.png
+++ b/docs/narr/project.png
Binary files differ
diff --git a/docs/narr/project.rst b/docs/narr/project.rst
index 118a9fa89..61759fe34 100644
--- a/docs/narr/project.rst
+++ b/docs/narr/project.rst
@@ -23,7 +23,7 @@ These cookiecutters are rendered using the ``cookiecutter`` command that you may
.. seealso::
-
+ See also `Cookiecutter Installation <https://cookiecutter.readthedocs.io/en/latest/installation.html>`_.
.. index::
@@ -37,73 +37,103 @@ These cookiecutters are rendered using the ``cookiecutter`` command that you may
:app:`Pyramid` cookiecutters
----------------------------
-Pyramid cookiecutters released under the Pylons Project include:
-
-* `pyramid-cookiecutter-alchemy <https://github.com/Pylons/pyramid-cookiecutter-alchemy>`_
-* `pyramid-cookiecutter-starter <https://github.com/Pylons/pyramid-cookiecutter-starter>`_
-* `pyramid-cookiecutter-zodb <https://github.com/Pylons/pyramid-cookiecutter-zodb>`_
+Pyramid cookiecutters released under the Pylons Project include differ from each other on a number of axes:
+- the persistence mechanism they offer (no persistence mechanism, :term:`SQLAlchemy` with SQLite, or :term:`ZODB`)
-The convenience scaffolds included with :app:`Pyramid` differ from each other
-on a number of axes:
+- the mechanism they use to map URLs to code (:term:`URL dispatch` or :term:`traversal`)
-- the persistence mechanism they offer (no persistence mechanism, :term:`ZODB`,
- or :term:`SQLAlchemy`)
+- templating libraries (:term:`Jinja2` or :term:`Chameleon`)
-- the mechanism they use to map URLs to code (:term:`traversal` or :term:`URL
- dispatch`)
+* `pyramid-cookiecutter-starter <https://github.com/Pylons/pyramid-cookiecutter-starter>`_
+* `pyramid-cookiecutter-alchemy <https://github.com/Pylons/pyramid-cookiecutter-alchemy>`_
+* `pyramid-cookiecutter-zodb <https://github.com/Pylons/pyramid-cookiecutter-zodb>`_
-The included scaffolds are these:
+These cookiecutters include:
-``starter``
- URL mapping via :term:`URL dispatch` and no persistence mechanism
+``pyramid-cookiecutter-starter``
+ :term:`URL dispatch` for routing and :term:`Jinja2` for templating
-``zodb``
- URL mapping via :term:`traversal` and persistence via :term:`ZODB`
+``pyramid-cookiecutter-alchemy``
+ SQLite for persistent storage, :term:`SQLAlchemy` for an ORM, :term:`URL dispatch` for routing, and :term:`Jinja2` for templating.
-``alchemy``
- URL mapping via :term:`URL dispatch` and persistence via :term:`SQLAlchemy`
+``pyramid-cookiecutter-zodb``
+ :term:`ZODB` for persistent storage, :term:`traversal` for routing, and :term:`Chameleon` for templating
.. index::
single: creating a project
single: project
- single: pcreate
+ single: cookiecutter
.. _creating_a_project:
Creating the Project
--------------------
-.. seealso:: See also the output of :ref:`pcreate --help <pcreate_script>`.
-
In :ref:`installing_chapter`, you created a virtual Python environment via the
-``venv`` command. To start a :app:`Pyramid` :term:`project`, use the
-``pcreate`` command installed within the virtual environment. We'll choose the
-``starter`` scaffold for this purpose. When we invoke ``pcreate``, it will
-create a directory that represents our project.
+``venv`` command. We called the virtual environment directory
+``env`` and set an environment variable ``VENV`` to its path.
+
+We assume that you previously installed cookiecutter using the following command:
+
+.. code-block:: bash
+
+ $ $VENV/bin/pip install cookiecutter
-In :ref:`installing_chapter` we called the virtual environment directory
-``env``. The following commands assume that our current working directory is
-the ``env`` directory.
+We'll choose ``pyramid-cookiecutter-starter`` to start the project. When we invoke ``cookiecutter``, it will create a directory that represents our project.
-The below example uses the ``pcreate`` command to create a project with the
-``starter`` scaffold.
+The following commands assume that our current working directory is the value of ``$VENV``.
On UNIX:
.. code-block:: bash
- $ $VENV/bin/pcreate -s starter MyProject
+ $ $VENV/bin/cookiecutter https://github.com/Pylons/pyramid-cookiecutter-starter
Or on Windows:
.. code-block:: doscon
- c:\> %VENV%\Scripts\pcreate -s starter MyProject
+ c:\> %VENV%\cookiecutter https://github.com/Pylons/pyramid-cookiecutter-starter
+
+If prompted for the first item, accept the default ``yes`` by hitting return.
+
+#. ``You've cloned ~/.cookiecutters/pyramid-cookiecutter-starter before. Is it
+ okay to delete and re-clone it? [yes]:``
+#. ``project_name [Pyramid Scaffold]: myproject``
+#. ``repo_name [scaffold]: myproject``
+
+We then run through the following commands.
+
+On UNIX:
+
+.. code-block:: bash
+
+ # Reset our environment variable for a new virtual environment.
+ $ export VENV=~/env/myproject/env
+ # Change directory into your newly created project.
+ $ cd myproject
+ # Create a new virtual environment...
+ $ python3 -m venv $VENV
+ # ...where we upgrade packaging tools.
+ $ env/bin/pip install --upgrade pip setuptools
+
+Or on Windows:
+
+.. code-block:: doscon
-As a result of invoking the ``pcreate`` command, a directory named
-``MyProject`` is created. That directory is a :term:`project` directory. The
+ # Reset our environment variable for a new virtual environment.
+ c:\> set VENV=c:\env\myproject\env
+ # Change directory into your newly created project.
+ c:\> cd myproject
+ # Create a new virtual environment...
+ c:\myproject\> c:\Python3x\python -m venv %VENV%
+ # ...where we upgrade packaging tools.
+ c:\myproject\> %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
``setup.py`` file in that directory can be used to distribute your application,
or install your application for deployment or development.
@@ -118,15 +148,15 @@ debugger (to prevent inappropriate access and disclosure), and turns off a
number of debugging settings. You can use this file to put your application
into production.
-The ``MyProject`` project directory contains an additional subdirectory named
+The ``myproject`` project directory contains an additional subdirectory named
``myproject`` (note the case difference) representing a Python :term:`package`
which holds very simple :app:`Pyramid` sample code. This is where you'll edit
your application's Python code and templates.
-We created this project within an ``env`` virtual environment directory.
+We created this project in a directory next to its virtual environment directory.
However, note that this is not mandatory. The project directory can go more or
less anywhere on your filesystem. You don't need to put it in a special "web
-server" directory, and you don't need to put it within a virtual environment
+server" directory. You could put it within a virtual environment
directory. The author uses Linux mainly, and tends to put project directories
which he creates within his ``~/projects`` directory. On Windows, it's a good
idea to put project directories within a directory that contains no space
@@ -136,7 +166,7 @@ projects in ``C:\projects``.
.. warning::
- You'll need to avoid using ``pcreate`` to create a project with the same
+ You'll need to avoid using ``cookiecutter`` to create a project with the same
name as a Python standard library component. In particular, this means you
should avoid using the names ``site`` or ``test``, both of which conflict
with Python standard library packages. You should also avoid using the name
@@ -155,7 +185,7 @@ newly created project directory and use the Python interpreter from the
invoke the command ``pip install -e .``, which installs the project in
development mode (``-e`` is for "editable") into the current directory (``.``).
-The file named ``setup.py`` will be in the root of the pcreate-generated
+The file named ``setup.py`` will be in the root of the cookiecutter-generated
project directory. The ``python`` you're invoking should be the one that lives
in the ``bin`` (or ``Scripts`` on Windows) directory of your virtual Python
environment. Your terminal's current working directory *must* be the newly
@@ -165,25 +195,24 @@ On UNIX:
.. code-block:: bash
- $ cd MyProject
- $ $VENV/bin/pip install -e .
+ $ $VENV/bin/pip install -e .
Or on Windows:
.. code-block:: doscon
- c:\> cd MyProject
- c:\> %VENV%\Scripts\pip install -e .
+ c:\env\myproject\> %VENV%\Scripts\pip install -e .
Elided output from a run of this command on UNIX is shown below:
.. code-block:: bash
- $ cd MyProject
- $ $VENV/bin/pip install -e .
- ...
- Successfully installed Chameleon-2.24 Mako-1.0.4 MyProject \
- pyramid-chameleon-0.3 pyramid-debugtoolbar-2.4.2 pyramid-mako-1.0.2
+ 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 \
+ repoze.lru-0.6 translationstring-1.3 venusian-1.0 waitress-1.0.1 \
+ zope.deprecation-4.2.0 zope.interface-4.3.3
This will install a :term:`distribution` representing your project into the
virtual environment interpreter's library set so it can be found by ``import``
@@ -210,7 +239,7 @@ On Windows:
.. code-block:: doscon
- c:\> %VENV%\Scripts\pip install -e ".[testing]"
+ c:\env\myproject\> %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
@@ -226,7 +255,7 @@ On Windows:
.. code-block:: doscon
- c:\> %VENV%\Scripts\py.test -q
+ c:\env\myproject\> %VENV%\Scripts\py.test -q
Here's sample output from a test run on UNIX:
@@ -236,9 +265,7 @@ Here's sample output from a test run on UNIX:
..
2 passed in 0.47 seconds
-The tests themselves are found in the ``tests.py`` module in your ``pcreate``
-generated project. Within a project generated by the ``starter`` scaffold,
-only two sample tests exist.
+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.
.. note::
@@ -253,7 +280,7 @@ to ``py.test``:
$ $VENV/bin/py.test --cov -q
-Scaffolds include configuration defaults for ``py.test`` and test coverage.
+Cookiecutters include configuration defaults for ``py.test`` and test coverage.
These configuration files are ``pytest.ini`` and ``.coveragerc``, located at
the root of your package. Without these defaults, we would need to specify the
path to the module on which we want to run tests and coverage.
@@ -291,19 +318,18 @@ On UNIX:
On Windows:
-.. code-block:: text
+.. code-block:: doscon
- c:\> %VENV%\Scripts\pserve development.ini
+ c:\env\myproject\> %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 16208.
- Serving on http://127.0.0.1:6543
- Serving on http://[::1]:6543
-
+ 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
@@ -340,8 +366,8 @@ You can shut down a server started this way by pressing ``Ctrl-C`` (or
``Ctrl-Break`` on Windows).
The default server used to run your Pyramid application when a project is
-created from a scaffold is named :term:`Waitress`. This server is what prints
-the ``serving on...`` line when you run ``pserve``. It's a good idea to use
+created from a cookiecutter is named :term:`Waitress`. This server is what prints
+the ``Serving on...`` line when you run ``pserve``. It's a good idea to use
this server during development because it's very simple. It can also be used
for light production. Setting your application up under a different server is
not advised until you've done some development work under the default server,
@@ -378,7 +404,8 @@ For example, on UNIX:
$ $VENV/bin/pserve development.ini --reload
Starting subprocess with file monitor
Starting server in PID 16601.
- serving on http://127.0.0.1:6543
+ 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:
@@ -388,12 +415,13 @@ files, you'll see the server restart automatically:
development.ini changed; reloading...
-------------------- Restarting --------------------
Starting server in PID 16602.
- serving on http://127.0.0.1:6543
+ 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
long as the ``pyramid.reload_templates`` setting in the ``development.ini``
-file is ``true``. Changes made to template files when this setting is true
+file is ``true``. Changes made to template files when this setting is ``true``
will take effect immediately without a server restart.
.. index::
@@ -408,8 +436,8 @@ browser like what is displayed in the following image:
.. image:: project.png
-This is the page shown by default when you visit an unmodified ``pcreate``
-generated ``starter`` application in a browser.
+This is the page shown by default when you visit an unmodified ``cookiecutter``
+generated ``pyramid-cookiecutter-starter`` application in a browser.
.. index::
single: debug toolbar
@@ -490,48 +518,57 @@ this:
The Project Structure
---------------------
-The ``starter`` scaffold generated a :term:`project` (named ``MyProject``),
+The ``pyramid-cookiecutter-starter`` cookiecutter generated a :term:`project` (named ``myproject``),
which contains a Python :term:`package`. The package is *also* named
-``myproject``, but it's lowercased; the scaffold generates a project which
-contains a package that shares its name except for case.
+``myproject``; the cookiecutter generates a project which
+contains a package that shares its name.
-All :app:`Pyramid` ``pcreate``-generated projects share a similar structure.
-The ``MyProject`` project we've generated has the following directory structure:
+All :app:`Pyramid` ``cookiecutter``-generated projects share a similar structure.
+The ``myproject`` project we've generated has the following directory structure:
.. code-block:: text
- MyProject/
- |-- CHANGES.txt
- |-- development.ini
- |-- MANIFEST.in
- |-- myproject
- | |-- __init__.py
- | |-- static
- | | |-- pyramid-16x16.png
- | | |-- pyramid.png
- | | |-- theme.css
- | | `-- theme.min.css
- | |-- templates
- | | `-- mytemplate.pt
- | |-- tests.py
- | `-- views.py
- |-- production.ini
- |-- README.txt
- `-- setup.py
-
-The ``MyProject`` :term:`Project`
+ 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`
---------------------------------
-The ``MyProject`` :term:`project` directory is the distribution and deployment
+The ``myproject`` :term:`project` directory is the distribution and deployment
wrapper for your application. It contains both the ``myproject``
:term:`package` representing your application as well as files used to
describe, run, and test your application.
+#. ``.coveragerc`` configures coverage when running tests.
+
#. ``CHANGES.txt`` describes the changes you've made to the application. It is
- conventionally written in :term:`ReStructuredText` format.
+ conventionally written in :term:`reStructuredText` format.
+
+#. ``MANIFEST.in`` is a :term:`distutils` "manifest" file, naming which files
+ should be included in a source distribution of the package when ``python
+ setup.py sdist`` is run.
#. ``README.txt`` describes the application in general. It is conventionally
- written in :term:`ReStructuredText` format.
+ written in :term:`reStructuredText` format.
#. ``development.ini`` is a :term:`PasteDeploy` configuration file that can be
used to execute your application during development.
@@ -539,9 +576,7 @@ describe, run, and test your application.
#. ``production.ini`` is a :term:`PasteDeploy` configuration file that can be
used to execute your application in a production configuration.
-#. ``MANIFEST.in`` is a :term:`distutils` "manifest" file, naming which files
- should be included in a source distribution of the package when ``python
- setup.py sdist`` is run.
+#. ``pytest.ini`` is a configuration file for running tests.
#. ``setup.py`` is the file you'll use to test and distribute your application.
It is a standard :term:`setuptools` ``setup.py`` file.
@@ -550,7 +585,7 @@ describe, run, and test your application.
single: PasteDeploy
single: ini file
-.. _MyProject_ini:
+.. _myproject_ini:
``development.ini``
~~~~~~~~~~~~~~~~~~~
@@ -561,7 +596,7 @@ as the deployment settings provided to that application.
The generated ``development.ini`` file looks like so:
-.. literalinclude:: MyProject/development.ini
+.. literalinclude:: myproject/development.ini
:language: ini
:linenos:
@@ -570,15 +605,15 @@ This file contains several sections including ``[app:main]``,
The ``[app:main]`` section represents configuration for your :app:`Pyramid`
application. The ``use`` setting is the only setting required to be present in
-the ``[app:main]`` section. Its default value, ``egg:MyProject``, indicates
-that our MyProject project contains the application that should be served.
+the ``[app:main]`` section. Its default value, ``egg:myproject``, indicates
+that our myproject project contains the application that should be served.
Other settings added to this section are passed as keyword arguments to the
function named ``main`` in our package's ``__init__.py`` module. You can
provide startup-time configuration parameters to your application by adding
more settings to this section.
.. seealso:: See :ref:`pastedeploy_entry_points` for more information about the
- meaning of the ``use = egg:MyProject`` value in this section.
+ meaning of the ``use = egg:myproject`` value in this section.
The ``pyramid.reload_templates`` setting in the ``[app:main]`` section is a
:app:`Pyramid`-specific setting which is passed into the framework. If it
@@ -612,7 +647,7 @@ The ``[server:main]`` section of the configuration file configures a WSGI
server which listens on TCP port 6543. It is configured to listen on localhost
only (``127.0.0.1``).
-.. _MyProject_ini_logging:
+.. _myproject_ini_logging:
The sections after ``# logging configuration`` represent Python's standard
library :mod:`logging` module configuration for your application. These
@@ -673,7 +708,7 @@ directory didn't contain a ``MANIFEST.in`` file that told the ``sdist``
machinery to include ``*.pt`` files, the ``myproject/templates/mytemplate.pt``
file would not be included in the generated tarball.
-Projects generated by Pyramid scaffolds include a default ``MANIFEST.in`` file.
+Projects generated by Pyramid cookiecutters include a default ``MANIFEST.in`` file.
The ``MANIFEST.in`` file contains declarations which tell it to include files
like ``*.pt``, ``*.css`` and ``*.js`` in the generated tarball. If you include
files with extensions other than the files named in the project's
@@ -713,7 +748,7 @@ testing, as well as distributing your application.
Our generated ``setup.py`` looks like this:
-.. literalinclude:: MyProject/setup.py
+.. literalinclude:: myproject/setup.py
:language: python
:linenos:
@@ -756,7 +791,7 @@ you can try this command now:
$ $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
+``myproject-0.0.tar.gz``. You can send this tarball to other people who want
to install and use your application.
.. index::
@@ -765,7 +800,7 @@ to install and use your application.
The ``myproject`` :term:`Package`
---------------------------------
-The ``myproject`` :term:`package` lives inside the ``MyProject``
+The ``myproject`` :term:`package` lives inside the ``myproject``
:term:`project`. It contains:
#. An ``__init__.py`` file signifies that this is a Python :term:`package`. It
@@ -773,14 +808,14 @@ The ``myproject`` :term:`package` lives inside the ``MyProject``
``main`` function which is used as a entry point for commands such as
``pserve``, ``pshell``, ``pviews``, and others.
-#. A ``templates`` directory, which contains :term:`Chameleon` (or other types
+#. A ``templates`` directory, which contains :term:`Jinja2` (or other types
of) templates.
#. A ``tests.py`` module, which contains unit test code for the application.
#. A ``views.py`` module, which contains view code for the application.
-These are purely conventions established by the scaffold. :app:`Pyramid`
+These are purely conventions established by the cookiecutter. :app:`Pyramid`
doesn't insist that you name things in any particular way. However, it's
generally a good idea to follow Pyramid standards for naming, so that other
Pyramid developers can get up to speed quickly on your code when you need help.
@@ -798,7 +833,7 @@ advertises an entry point for use by our :term:`PasteDeploy` ``.ini`` file.
This is the file named ``__init__.py``. The presence of an ``__init__.py``
also informs Python that the directory which contains it is a *package*.
-.. literalinclude:: MyProject/myproject/__init__.py
+.. literalinclude:: myproject/myproject/__init__.py
:language: python
:linenos:
@@ -813,8 +848,8 @@ also informs Python that the directory which contains it is a *package*.
Line 7 creates an instance of a :term:`Configurator`.
- Line 8 adds support for Chameleon templating bindings, allowing us to
- specify renderers with the ``.pt`` extension.
+ Line 8 adds support for Jinja2 templating bindings, allowing us to
+ specify renderers with the ``.jinja2`` extension.
Line 9 registers a static view, which will serve up the files from the
``myproject:static`` :term:`asset specification` (the ``static`` directory
@@ -840,7 +875,7 @@ callables*. A :term:`view callable` is the main tool of a :app:`Pyramid` web
application developer; it is a bit of code which accepts a :term:`request` and
which returns a :term:`response`.
-.. literalinclude:: MyProject/myproject/views.py
+.. literalinclude:: myproject/myproject/views.py
:language: python
:linenos:
@@ -857,8 +892,8 @@ result of the view callable. This particular view declaration points at
specifies the ``mytemplate.pt`` file within the ``templates`` directory of the
``myproject`` package. The asset specification could have also been specified
as ``myproject:templates/mytemplate.pt``; the leading package name and colon is
-optional. The template file pointed to is a :term:`Chameleon` ZPT template
-file (``templates/my_template.pt``).
+optional. The template file pointed to is a :term:`Jinja2` template
+file (``templates/my_template.jinja2``).
This view callable function is handed a single piece of information: the
:term:`request`. The *request* is an instance of the :term:`WebOb` ``Request``
@@ -871,9 +906,9 @@ the HTML in a :term:`response`.
.. note:: Dictionaries provide values to :term:`template`\s.
-.. note:: When the application is run with the scaffold's :ref:`default
- development.ini <MyProject_ini>` configuration, :ref:`logging is set up
- <MyProject_ini_logging>` to aid debugging. If an exception is raised,
+.. note:: When the application is run with the cookiecutter's :ref:`default
+ development.ini <myproject_ini>` configuration, :ref:`logging is set up
+ <myproject_ini_logging>` to aid debugging. If an exception is raised,
uncaught tracebacks are displayed after the startup messages on :ref:`the
console running the server <running_the_project_application>`. Also
``print()`` statements may be inserted into the application for debugging to
@@ -882,7 +917,7 @@ the HTML in a :term:`response`.
.. note:: ``development.ini`` has a setting that controls how templates are
reloaded, ``pyramid.reload_templates``.
- - When set to ``True`` (as in the scaffold ``development.ini``), changed
+ - When set to ``True`` (as in the cookiecutter ``development.ini``), changed
templates automatically reload without a server restart. This is
convenient while developing, but slows template rendering speed.
@@ -913,31 +948,46 @@ the HTML in a :term:`response`.
``static``
~~~~~~~~~~
-This directory contains static assets which support the ``mytemplate.pt``
+This directory contains static assets which support the ``layout.jinja2``
template. It includes CSS and images.
-``templates/mytemplate.pt``
+
+``templates/layout.jinja2``
~~~~~~~~~~~~~~~~~~~~~~~~~~~
-This is the single :term:`Chameleon` template that exists in the project. Its
-contents are too long to show here, but it displays a default page when
-rendered. It is referenced by the call to ``@view_config`` as the ``renderer``
+This is the base layout content. It contains a single marker for content block. Other templates inherit its content, providing layout for the web application. Its contents are too long to show here, but here is an excerpt:
+
+.. literalinclude:: myproject/myproject/templates/layout.jinja2
+ :language: jinja
+ :lines: 34-38
+ :lineno-match:
+
+
+``templates/mytemplate.jinja2``
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+This is the content :term:`Jinja2` template that exists in the project. It is referenced by the call to ``@view_config`` as the ``renderer``
of the ``my_view`` view callable in the ``views.py`` file. See
-:ref:`views_which_use_a_renderer` for more information about renderers.
+:ref:`views_which_use_a_renderer` for more information about renderers. It inherits ("extends") the HTML provided by ``layout.jinja2``, replacing the content block with its own content.
+
+.. literalinclude:: myproject/myproject/templates/mytemplate.jinja2
+ :language: jinja
+ :linenos:
Templates are accessed and used by view configurations and sometimes by view
functions themselves. See :ref:`templates_used_directly` and
:ref:`templates_used_as_renderers`.
+
.. index::
single: tests.py
``tests.py``
~~~~~~~~~~~~
-The ``tests.py`` module includes unit tests for your application.
+The ``tests.py`` module includes tests for your application.
-.. literalinclude:: MyProject/myproject/tests.py
+.. literalinclude:: myproject/myproject/tests.py
:language: python
:linenos:
@@ -959,16 +1009,16 @@ Modifying Package Structure
---------------------------
It is best practice for your application's code layout to not stray too much
-from accepted Pyramid scaffold defaults. If you refrain from changing things
+from accepted Pyramid cookiecutter defaults. If you refrain from changing things
very much, other Pyramid coders will be able to more quickly understand your
-application. However, the code layout choices made for you by a scaffold are
+application. However, the code layout choices made for you by a cookiecutter are
in no way magical or required. Despite the choices made for you by any
-scaffold, you can decide to lay your code out any way you see fit.
+cookiecutter, you can decide to lay your code out any way you see fit.
For example, the configuration method named
:meth:`~pyramid.config.Configurator.add_view` requires you to pass a
:term:`dotted Python name` or a direct object reference as the class or
-function to be used as a view. By default, the ``starter`` scaffold would have
+function to be used as a view. By default, the ``starter`` cookiecutter would have
you add view functions to the ``views.py`` module in your package. However, you
might be more comfortable creating a ``views`` *directory*, and adding a single
file for each view.
@@ -1010,7 +1060,7 @@ Pyramid application via ``pserve``. This can be a useful debugging tool. See
What Is This ``pserve`` Thing
-----------------------------
-The code generated by a :app:`Pyramid` scaffold assumes that you will be using
+The code generated by a :app:`Pyramid` cookiecutter assumes that you will be using
the ``pserve`` command to start your application while you do development.
``pserve`` is a command that reads a :term:`PasteDeploy` ``.ini`` file (e.g.,
``development.ini``), and configures a server to serve a :app:`Pyramid`
@@ -1020,7 +1070,7 @@ application based on the data in the file.
application. As we saw in :ref:`firstapp_chapter`, ``pserve`` needn't be
invoked at all to run a :app:`Pyramid` application. The use of ``pserve`` to
run a :app:`Pyramid` application is purely conventional based on the output of
-its scaffolding. But we strongly recommend using ``pserve`` while developing
+its cookiecutter. But we strongly recommend using ``pserve`` while developing
your application because many other convenience introspection commands (such as
``pviews``, ``prequest``, ``proutes``, and others) are also implemented in
terms of configuration availability of this ``.ini`` file format. It also
@@ -1032,7 +1082,7 @@ restarting of the server when code changes.
Using an Alternate WSGI Server
------------------------------
-Pyramid scaffolds generate projects which use the :term:`Waitress` WSGI server.
+Pyramid cookiecutters generate projects which use the :term:`Waitress` WSGI server.
Waitress is a server that is suited for development and light production
usage. It's not the fastest nor the most featureful WSGI server. Instead, its
main feature is that it works on all platforms that Pyramid needs to run on,