summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorChris McDonough <chrism@plope.com>2013-02-09 19:15:07 -0500
committerChris McDonough <chrism@plope.com>2013-02-09 19:15:07 -0500
commitacf115391088770ae434d222179fd22a693bfe46 (patch)
tree442d33920cd6d20ccb7ce3cff3344fd851448d0d /docs
parent6313e0dd97e22b8c897293cd8d5f2f145637f49f (diff)
parent7fe736bf57696aa62c8b0d84e62ad486d0f88f40 (diff)
downloadpyramid-acf115391088770ae434d222179fd22a693bfe46.tar.gz
pyramid-acf115391088770ae434d222179fd22a693bfe46.tar.bz2
pyramid-acf115391088770ae434d222179fd22a693bfe46.zip
Merge branch 'master' of github.com:Pylons/pyramid
Diffstat (limited to 'docs')
-rw-r--r--docs/api/config.rst10
-rw-r--r--docs/api/paster.rst2
-rw-r--r--docs/api/path.rst3
-rw-r--r--docs/api/registry.rst23
-rw-r--r--docs/api/request.rst6
-rw-r--r--docs/conf.py38
-rw-r--r--docs/designdefense.rst10
-rw-r--r--docs/glossary.rst13
-rw-r--r--docs/index.rst9
-rwxr-xr-xdocs/make_book2
-rwxr-xr-xdocs/make_epub2
-rwxr-xr-xdocs/make_pdf2
-rw-r--r--docs/narr/MyProject/myproject/__init__.py1
-rw-r--r--docs/narr/MyProject/myproject/tests.py1
-rw-r--r--docs/narr/MyProject/myproject/views.py3
-rw-r--r--docs/narr/MyProject/setup.py6
-rw-r--r--docs/narr/advconfig.rst4
-rw-r--r--docs/narr/assets.rst2
-rw-r--r--docs/narr/commandline.rst5
-rw-r--r--docs/narr/configuration.rst41
-rw-r--r--docs/narr/environment.rst7
-rw-r--r--docs/narr/extconfig.rst6
-rw-r--r--docs/narr/extending.rst2
-rw-r--r--docs/narr/firstapp.rst10
-rw-r--r--docs/narr/hooks.rst21
-rw-r--r--docs/narr/hybrid.rst2
-rw-r--r--docs/narr/i18n.rst2
-rw-r--r--docs/narr/install.rst80
-rw-r--r--docs/narr/introduction.rst6
-rw-r--r--docs/narr/introspector.rst19
-rw-r--r--docs/narr/project.rst16
-rw-r--r--docs/narr/renderers.rst45
-rw-r--r--docs/narr/sessions.rst2
-rw-r--r--docs/narr/subrequest.rst2
-rw-r--r--docs/narr/templates.rst10
-rw-r--r--docs/narr/upgrading.rst2
-rw-r--r--docs/narr/urldispatch.rst17
-rw-r--r--docs/narr/viewconfig.rst12
-rw-r--r--docs/narr/views.rst6
-rw-r--r--docs/narr/webob.rst2
-rwxr-xr-xdocs/remake2
-rw-r--r--docs/tutorials/wiki/authorization.rst9
-rw-r--r--docs/tutorials/wiki/background.rst2
-rw-r--r--docs/tutorials/wiki/basiclayout.rst49
-rw-r--r--docs/tutorials/wiki/definingmodels.rst9
-rw-r--r--docs/tutorials/wiki/definingviews.rst5
-rw-r--r--docs/tutorials/wiki/design.rst12
-rw-r--r--docs/tutorials/wiki/index.rst5
-rw-r--r--docs/tutorials/wiki/installation.rst102
-rw-r--r--docs/tutorials/wiki/src/authorization/development.ini28
-rw-r--r--docs/tutorials/wiki/src/authorization/production.ini17
-rw-r--r--docs/tutorials/wiki/src/authorization/setup.py9
-rw-r--r--docs/tutorials/wiki/src/authorization/tutorial/__init__.py3
-rw-r--r--docs/tutorials/wiki/src/authorization/tutorial/templates/mytemplate.pt6
-rw-r--r--docs/tutorials/wiki/src/authorization/tutorial/tests.py9
-rw-r--r--docs/tutorials/wiki/src/authorization/tutorial/views.py10
-rw-r--r--docs/tutorials/wiki/src/basiclayout/development.ini30
-rw-r--r--docs/tutorials/wiki/src/basiclayout/production.ini17
-rw-r--r--docs/tutorials/wiki/src/basiclayout/setup.py12
-rw-r--r--docs/tutorials/wiki/src/basiclayout/tutorial/__init__.py2
-rw-r--r--docs/tutorials/wiki/src/basiclayout/tutorial/models.py2
-rw-r--r--docs/tutorials/wiki/src/basiclayout/tutorial/templates/mytemplate.pt4
-rw-r--r--docs/tutorials/wiki/src/basiclayout/tutorial/tests.py1
-rw-r--r--docs/tutorials/wiki/src/basiclayout/tutorial/views.py3
-rw-r--r--docs/tutorials/wiki/src/models/development.ini28
-rw-r--r--docs/tutorials/wiki/src/models/production.ini17
-rw-r--r--docs/tutorials/wiki/src/models/setup.py12
-rw-r--r--docs/tutorials/wiki/src/models/tutorial/__init__.py5
-rw-r--r--docs/tutorials/wiki/src/models/tutorial/templates/mytemplate.pt6
-rw-r--r--docs/tutorials/wiki/src/models/tutorial/views.py6
-rw-r--r--docs/tutorials/wiki/src/tests/development.ini28
-rw-r--r--docs/tutorials/wiki/src/tests/production.ini17
-rw-r--r--docs/tutorials/wiki/src/tests/setup.py9
-rw-r--r--docs/tutorials/wiki/src/tests/tutorial/__init__.py3
-rw-r--r--docs/tutorials/wiki/src/tests/tutorial/templates/mytemplate.pt6
-rw-r--r--docs/tutorials/wiki/src/tests/tutorial/tests.py3
-rw-r--r--docs/tutorials/wiki/src/tests/tutorial/views.py10
-rw-r--r--docs/tutorials/wiki/src/views/development.ini30
-rw-r--r--docs/tutorials/wiki/src/views/production.ini17
-rw-r--r--docs/tutorials/wiki/src/views/setup.py8
-rw-r--r--docs/tutorials/wiki/src/views/tutorial/__init__.py8
-rw-r--r--docs/tutorials/wiki/src/views/tutorial/templates/mytemplate.pt6
-rw-r--r--docs/tutorials/wiki/src/views/tutorial/tests.py27
-rw-r--r--docs/tutorials/wiki/src/views/tutorial/views.py4
-rw-r--r--docs/tutorials/wiki/tests.rst14
-rw-r--r--docs/tutorials/wiki2/authorization.rst34
-rw-r--r--docs/tutorials/wiki2/background.rst5
-rw-r--r--docs/tutorials/wiki2/basiclayout.rst51
-rw-r--r--docs/tutorials/wiki2/definingmodels.rst39
-rw-r--r--docs/tutorials/wiki2/definingviews.rst43
-rw-r--r--docs/tutorials/wiki2/design.rst2
-rw-r--r--docs/tutorials/wiki2/index.rst6
-rw-r--r--docs/tutorials/wiki2/installation.rst54
-rw-r--r--docs/tutorials/wiki2/src/authorization/README.txt13
-rw-r--r--docs/tutorials/wiki2/src/authorization/development.ini20
-rw-r--r--docs/tutorials/wiki2/src/authorization/setup.py10
-rw-r--r--docs/tutorials/wiki2/src/authorization/tutorial/__init__.py2
-rw-r--r--docs/tutorials/wiki2/src/authorization/tutorial/models.py1
-rw-r--r--docs/tutorials/wiki2/src/authorization/tutorial/scripts/initializedb.py4
-rw-r--r--docs/tutorials/wiki2/src/authorization/tutorial/tests.py1
-rw-r--r--docs/tutorials/wiki2/src/basiclayout/README.txt13
-rw-r--r--docs/tutorials/wiki2/src/basiclayout/development.ini20
-rw-r--r--docs/tutorials/wiki2/src/basiclayout/production.ini12
-rw-r--r--docs/tutorials/wiki2/src/basiclayout/setup.py9
-rw-r--r--docs/tutorials/wiki2/src/basiclayout/tutorial/__init__.py2
-rw-r--r--docs/tutorials/wiki2/src/basiclayout/tutorial/models.py2
-rw-r--r--docs/tutorials/wiki2/src/basiclayout/tutorial/scripts/initializedb.py4
-rw-r--r--docs/tutorials/wiki2/src/basiclayout/tutorial/templates/mytemplate.pt2
-rw-r--r--docs/tutorials/wiki2/src/basiclayout/tutorial/tests.py1
-rw-r--r--docs/tutorials/wiki2/src/basiclayout/tutorial/views.py28
-rw-r--r--docs/tutorials/wiki2/src/models/README.txt13
-rw-r--r--docs/tutorials/wiki2/src/models/development.ini20
-rw-r--r--docs/tutorials/wiki2/src/models/setup.py9
-rw-r--r--docs/tutorials/wiki2/src/models/tutorial/__init__.py2
-rw-r--r--docs/tutorials/wiki2/src/models/tutorial/models.py2
-rw-r--r--docs/tutorials/wiki2/src/models/tutorial/scripts/initializedb.py4
-rw-r--r--docs/tutorials/wiki2/src/models/tutorial/tests.py1
-rw-r--r--docs/tutorials/wiki2/src/models/tutorial/views.py28
-rw-r--r--docs/tutorials/wiki2/src/tests/README.txt13
-rw-r--r--docs/tutorials/wiki2/src/tests/development.ini20
-rw-r--r--docs/tutorials/wiki2/src/tests/setup.py8
-rw-r--r--docs/tutorials/wiki2/src/tests/tutorial/__init__.py2
-rw-r--r--docs/tutorials/wiki2/src/tests/tutorial/models.py1
-rw-r--r--docs/tutorials/wiki2/src/tests/tutorial/scripts/initializedb.py4
-rw-r--r--docs/tutorials/wiki2/src/tests/tutorial/tests.py8
-rw-r--r--docs/tutorials/wiki2/src/tests/tutorial/views.py13
-rw-r--r--docs/tutorials/wiki2/src/views/README.txt13
-rw-r--r--docs/tutorials/wiki2/src/views/development.ini20
-rw-r--r--docs/tutorials/wiki2/src/views/setup.py9
-rw-r--r--docs/tutorials/wiki2/src/views/tutorial/__init__.py1
-rw-r--r--docs/tutorials/wiki2/src/views/tutorial/models.py2
-rw-r--r--docs/tutorials/wiki2/src/views/tutorial/scripts/initializedb.py4
-rw-r--r--docs/tutorials/wiki2/src/views/tutorial/tests.py1
-rw-r--r--docs/tutorials/wiki2/tests.rst3
-rw-r--r--docs/whatsnew-1.4.rst17
135 files changed, 956 insertions, 704 deletions
diff --git a/docs/api/config.rst b/docs/api/config.rst
index 5d2bce23e..39d504348 100644
--- a/docs/api/config.rst
+++ b/docs/api/config.rst
@@ -108,9 +108,7 @@
:class:`pyramid.registry.Introspectable` class (used during
directives to provide introspection to actions).
- .. note::
-
- This attribute is new as of :app:`Pyramid` 1.3.
+ .. versionadded:: 1.3
.. attribute:: introspector
@@ -118,9 +116,7 @@
instance implementing the :class:`pyramid.interfaces.IIntrospector`
interface.
- .. note::
-
- This attribute is new as of :app:`Pyramid` 1.3.
+ .. versionadded:: 1.3
.. attribute:: registry
@@ -130,7 +126,7 @@
.. attribute:: global_registries
The set of registries that have been created for :app:`Pyramid`
- applications, one per each call to
+ applications, one for each call to
:meth:`pyramid.config.Configurator.make_wsgi_app` in the current
process. The object itself supports iteration and has a ``last`` property
containing the last registry loaded.
diff --git a/docs/api/paster.rst b/docs/api/paster.rst
index 3f7a1c364..bde128e05 100644
--- a/docs/api/paster.rst
+++ b/docs/api/paster.rst
@@ -7,7 +7,7 @@
.. autofunction:: bootstrap
- .. autofunction:: get_app(config_uri, name=None)
+ .. autofunction:: get_app(config_uri, name=None, options=None)
.. autofunction:: get_appsettings(config_uri, name=None)
diff --git a/docs/api/path.rst b/docs/api/path.rst
index d46c35d8e..814fc47d5 100644
--- a/docs/api/path.rst
+++ b/docs/api/path.rst
@@ -9,8 +9,7 @@
A constant used by the constructor of
:class:`pyramid.path.DottedNameResolver` and
- :class:`pyramid.path.AssetResolver` (see their docstrings for more
- info).
+ :class:`pyramid.path.AssetResolver`.
.. autoclass:: DottedNameResolver
:members:
diff --git a/docs/api/registry.rst b/docs/api/registry.rst
index 1d5d52248..db348495c 100644
--- a/docs/api/registry.rst
+++ b/docs/api/registry.rst
@@ -14,12 +14,14 @@
accessed as ``request.registry.settings`` or
``config.registry.settings`` in a typical Pyramid application.
- .. attribute:: introspector
+ .. attribute:: introspector
+
+ .. versionadded:: 1.3
When a registry is set up (or created) by a :term:`Configurator`, the
registry will be decorated with an instance named ``introspector``
implementing the :class:`pyramid.interfaces.IIntrospector` interface.
- See also :attr:`pyramid.config.Configurator.introspector``.
+ See also :attr:`pyramid.config.Configurator.introspector`.
When a registry is created "by hand", however, this attribute will not
exist until set up by a configurator.
@@ -27,28 +29,23 @@
This attribute is often accessed as ``request.registry.introspector`` in
a typical Pyramid application.
- This attribute is new as of :app:`Pyramid` 1.3.
-
.. class:: Introspectable
+ .. versionadded:: 1.3
+
The default implementation of the interface
:class:`pyramid.interfaces.IIntrospectable` used by framework exenders.
- An instance of this class is is created when
+ An instance of this class is created when
:attr:`pyramid.config.Configurator.introspectable` is called.
- This class is new as of :app:`Pyramid` 1.3.
-
.. autoclass:: Deferred
- This class is new as of :app:`Pyramid` 1.4.
+ .. versionadded:: 1.4
.. autofunction:: undefer
- This function is new as of :app:`Pyramid` 1.4.
+ .. versionadded:: 1.4
.. autoclass:: predvalseq
- This class is new as of :app:`Pyramid` 1.4.
-
-
-
+ .. versionadded:: 1.4
diff --git a/docs/api/request.rst b/docs/api/request.rst
index 3a1439874..9f1f71b31 100644
--- a/docs/api/request.rst
+++ b/docs/api/request.rst
@@ -163,9 +163,7 @@
.. method:: invoke_subrequest(request, use_tweens=False)
- .. warning::
-
- This API was added in Pyramid 1.4a1.
+ .. versionadded:: 1.4a1
Obtain a response object from the Pyramid application based on
information in the ``request`` object provided. The ``request`` object
@@ -251,7 +249,7 @@
Assigning to one is still supported but will cause a deprecation
warning to be emitted, and eventually the feature will be removed. For
new code, instead of assigning ``response_*`` attributes to the
- request, use API of the the :attr:`pyramid.request.Request.response`
+ request, use API of the :attr:`pyramid.request.Request.response`
object (exposed to view code as ``request.response``) to influence
rendered response behavior.
diff --git a/docs/conf.py b/docs/conf.py
index 5e17de18a..6eb76af9d 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -26,6 +26,7 @@ from sphinx.writers.latex import LaTeXTranslator
from docutils import nodes
from docutils import utils
+
def raw(*arg):
raise nodes.SkipNode
TextTranslator.visit_raw = raw
@@ -75,13 +76,14 @@ master_doc = 'index'
# General substitutions.
project = 'The Pyramid Web Application Development Framework'
-copyright = '%s, Agendaless Consulting' % datetime.datetime.now().year
+thisyear = datetime.datetime.now().year
+copyright = '2008-%s, Agendaless Consulting' % thisyear
# The default replacements for |version| and |release|, also used in various
# other places throughout the built documents.
#
# The short X.Y version.
-version = '1.4a4'
+version = '1.4'
# The full version, including alpha/beta/rc tags.
release = version
@@ -97,7 +99,7 @@ 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 = ['_themes/README.rst',]
+exclude_patterns = ['_themes/README.rst', ]
# List of directories, relative to source directories, that shouldn't be searched
# for source files.
@@ -129,14 +131,12 @@ if book:
# -----------------------
# Add and use Pylons theme
-if 'sphinx-build' in ' '.join(sys.argv): # protect against dumb importers
+if 'sphinx-build' in ' '.join(sys.argv): # protect against dumb importers
from subprocess import call, Popen, PIPE
p = Popen('which git', shell=True, stdout=PIPE)
-
cwd = os.getcwd()
_themes = os.path.join(cwd, '_themes')
- p = Popen('which git', shell=True, stdout=PIPE)
git = p.stdout.read().strip()
if not os.listdir(_themes):
call([git, 'submodule', '--init'])
@@ -235,6 +235,8 @@ latex_paper_size = 'letter'
# The font size ('10pt', '11pt' or '12pt').
latex_font_size = '10pt'
+latex_additional_files = ['_static/latex-note.png', '_static/latex-warning.png']
+
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title, author, document class [howto/manual]).
latex_documents = [
@@ -371,10 +373,10 @@ _PREAMBLE = r"""
latex_elements = {
'preamble': _PREAMBLE,
- 'wrapperclass':'book',
- 'date':'',
- 'releasename':'Version',
- 'title':r'The Pyramid Web Application \newline Development Framework',
+ 'wrapperclass': 'book',
+ 'date': '',
+ 'releasename': 'Version',
+ 'title': r'The Pyramid Web Application \newline Development Framework',
# 'pointsize':'12pt', # uncomment for 12pt version
}
@@ -390,6 +392,7 @@ latex_elements = {
#paragraph 4
#subparagraph 5
+
def frontmatter(name, arguments, options, content, lineno,
content_offset, block_text, state, state_machine):
return [nodes.raw(
@@ -407,6 +410,7 @@ def frontmatter(name, arguments, options, content, lineno,
""",
format='latex')]
+
def mainmatter(name, arguments, options, content, lineno,
content_offset, block_text, state, state_machine):
return [nodes.raw(
@@ -426,11 +430,13 @@ def mainmatter(name, arguments, options, content, lineno,
""",
format='latex')]
+
def backmatter(name, arguments, options, content, lineno,
content_offset, block_text, state, state_machine):
return [nodes.raw('', '\\backmatter\n\\setcounter{secnumdepth}{-1}\n',
format='latex')]
+
def app_role(role, rawtext, text, lineno, inliner, options={}, content=[]):
"""custom role for :app: marker, does nothing in particular except allow
:app:`Pyramid` to work (for later search and replace)."""
@@ -448,6 +454,7 @@ def setup(app):
app.add_directive('backmatter', backmatter, 1, (0, 0, 0))
app.connect('autodoc-process-signature', resig)
+
def resig(app, what, name, obj, options, signature, return_annotation):
""" Allow for preservation of ``@action_method`` decorated methods
in configurator """
@@ -474,10 +481,11 @@ def resig(app, what, name, obj, options, signature, return_annotation):
# -- Options for Epub output ---------------------------------------------------
# Bibliographic Dublin Core info.
-epub_title = 'The Pyramid Web Application Development Framework, Version 1.4'
+epub_title = 'The Pyramid Web Application Development Framework, Version %s' \
+ % release
epub_author = 'Chris McDonough'
epub_publisher = 'Agendaless Consulting'
-epub_copyright = '2008-2011'
+epub_copyright = '2008-%d' % thisyear
# The language of the text. It defaults to the language option
# or en if the language is not set.
@@ -491,8 +499,8 @@ epub_scheme = 'ISBN'
epub_identifier = '0615445675'
# A unique identification for the text.
-epub_uid = 'The Pyramid Web Application Development Framework, Version 1.4'
-
+epub_uid = 'The Pyramid Web Application Development Framework, Version %s' \
+ % release
# HTML files that should be inserted before the pages created by sphinx.
# The format is a list of tuples containing the path and title.
#epub_pre_files = []
@@ -504,7 +512,7 @@ epub_uid = 'The Pyramid Web Application Development Framework, Version 1.4'
# A list of files that should not be packed into the epub file.
epub_exclude_files = ['_static/opensearch.xml', '_static/doctools.js',
'_static/jquery.js', '_static/searchtools.js', '_static/underscore.js',
- '_static/basic.css', 'search.html']
+ '_static/basic.css', 'search.html', '_static/websupport.js']
# The depth of the table of contents in toc.ncx.
diff --git a/docs/designdefense.rst b/docs/designdefense.rst
index b468ddac6..69a921498 100644
--- a/docs/designdefense.rst
+++ b/docs/designdefense.rst
@@ -38,7 +38,7 @@ forking is also a Zope derivative.
Implementations of these features were *required* to allow the :app:`Pyramid`
authors to build the bread-and-butter CMS-type systems for customers in the
-way they were accustomed to building them. No other system save Zope itself
+way they were accustomed to building them. No other system, save for Zope itself,
had such features. And Zope itself was beginning to show signs of its age.
We were becoming hampered by consequences of its early design mistakes.
Zope's lack of documentation was also difficult to work around: it was hard
@@ -55,7 +55,7 @@ existing frameworks had good, and sometimes very compelling ideas. In
particular, :term:`URL dispatch` is a more direct mechanism to map URLs to
code.
-So although we couldn't find a framework save for Zope that fit our needs,
+So, although we couldn't find a framework, save for Zope, that fit our needs,
and while we incorporated a lot of Zope ideas into BFG, we also emulated the
features we found compelling in other frameworks (such as :term:`url
dispatch`). After the initial public release of BFG, as time went on,
@@ -873,7 +873,7 @@ means:
#) When I use the security proxy machinery, I can have a view that
conditionally displays certain HTML elements (like form fields) or
- prevents certain attributes from being modified depending on the the
+ prevents certain attributes from being modified depending on the
permissions that the accessing user possesses with respect to a context
object.
@@ -919,7 +919,7 @@ creating a more Zope3-like environment without much effort.
Pyramid Uses its Own HTTP Exception Class Hierarchy Rather Than ``webob.exc``
-----------------------------------------------------------------------------
-.. note:: This defense is new as of Pyramid 1.1.
+.. versionadded:: 1.1
The HTTP exception classes defined in :mod:`pyramid.httpexceptions` are very
much like the ones defined in ``webob.exc``
@@ -1536,7 +1536,7 @@ comments take into account what we've discussed in the
.. code-block:: python
:linenos:
- from pyramid.response import Response # explicit response, no TL
+ from pyramid.response import Response # explicit response, no thread local
from wsgiref.simple_server import make_server # explicitly WSGI
def hello_world(request): # accepts a request; no request thread local reqd
diff --git a/docs/glossary.rst b/docs/glossary.rst
index adcf36f7c..9220e6b5f 100644
--- a/docs/glossary.rst
+++ b/docs/glossary.rst
@@ -486,8 +486,8 @@ Glossary
is in use.
physical root
- The object returned by the application :term:`root factory`. Unlike the
- the :term:`virtual root` of a request, it is not impacted by
+ The object returned by the application :term:`root factory`.
+ Unlike the :term:`virtual root` of a request, it is not impacted by
:ref:`vhosting_chapter`: it will always be the actual object returned by
the root factory, never a subobject.
@@ -689,7 +689,7 @@ Glossary
non-C based Python implementations.
View Lookup
- The act of finding and invoking the "best" :term:`view callable`
+ The act of finding and invoking the "best" :term:`view callable`,
given a :term:`request` and a :term:`context` resource.
Resource Location
@@ -840,7 +840,7 @@ Glossary
information.
Mako
- `Mako <http://www.makotemplates.org/>`_ is a template language language
+ `Mako <http://www.makotemplates.org/>`_ is a template language
which refines the familiar ideas of componentized layout and inheritance
using Python with Python scoping and calling semantics.
@@ -921,7 +921,7 @@ Glossary
PyPy
PyPy is an "alternative implementation of the Python
- language":http://pypy.org/
+ language": http://pypy.org/
tween
A bit of code that sits between the Pyramid router's main request
@@ -1015,8 +1015,7 @@ Glossary
Green Unicorn
Aka ``gunicorn``, a fast :term:`WSGI` server that runs on UNIX under
- Python 2.5+ (although at the time of this writing does not support
- Python 3). See http://gunicorn.org/ for detailed information.
+ Python 2.6+ or Python 3.1+. See http://gunicorn.org/ for detailed information.
predicate factory
A callable which is used by a third party during the registration of a
diff --git a/docs/index.rst b/docs/index.rst
index faf8258c1..d4b7ed492 100644
--- a/docs/index.rst
+++ b/docs/index.rst
@@ -14,7 +14,7 @@ Here is one of the simplest :app:`Pyramid` applications you can make:
.. literalinclude:: narr/helloworld.py
After you install :app:`Pyramid` and run this application, when you visit
-``http://localhost:8080/hello/world`` in a browser, you will see the text
+`<http://localhost:8080/hello/world>`_ in a browser, you will see the text
``Hello, world!``
See :ref:`firstapp_chapter` for a full explanation of how this application
@@ -138,6 +138,11 @@ Design Documents
Sample Applications
===================
+.. note::
+
+ These applications run only on Python 2.x, and so do some of their
+ dependencies.
+
`cluegun <https://github.com/Pylons/cluegun>`_ is a simple pastebin
application based on Rocky Burt's `ClueBin
<http://pypi.python.org/pypi/ClueBin/0.2.3>`_. It demonstrates form
@@ -200,7 +205,7 @@ To check out the trunk via ``git``, use this command:
To find out how to become a contributor to :app:`Pyramid`, please see the
`contributor's section of the documentation
-<http://docs.pylonsproject.org/index.html#contributing>`_.
+<http://docs.pylonsproject.org/en/latest/#contributing>`_.
Index and Glossary
==================
diff --git a/docs/make_book b/docs/make_book
index 22883ac4a..94e249441 100755
--- a/docs/make_book
+++ b/docs/make_book
@@ -1,4 +1,4 @@
#!/bin/sh
-make clean latex SPHINXBUILD=../env26/bin/sphinx-build BOOK=1
+make clean latex SPHINXBUILD=../env/bin/sphinx-build BOOK=1
cd _build/latex && make all-pdf
diff --git a/docs/make_epub b/docs/make_epub
index 868749e3b..cf9263451 100755
--- a/docs/make_epub
+++ b/docs/make_epub
@@ -1,2 +1,2 @@
#!/bin/sh
-make clean epub SPHINXBUILD=../env26/bin/sphinx-build
+make clean epub SPHINXBUILD=../env/bin/sphinx-build
diff --git a/docs/make_pdf b/docs/make_pdf
index 558feb857..6c9863bc9 100755
--- a/docs/make_pdf
+++ b/docs/make_pdf
@@ -1,4 +1,4 @@
#!/bin/sh
-make clean latex SPHINXBUILD=../env26/bin/sphinx-build
+make clean latex SPHINXBUILD=../env/bin/sphinx-build
cd _build/latex && make all-pdf
diff --git a/docs/narr/MyProject/myproject/__init__.py b/docs/narr/MyProject/myproject/__init__.py
index 31b02cf02..6c512f52f 100644
--- a/docs/narr/MyProject/myproject/__init__.py
+++ b/docs/narr/MyProject/myproject/__init__.py
@@ -1,5 +1,6 @@
from pyramid.config import Configurator
+
def main(global_config, **settings):
""" This function returns a Pyramid WSGI application.
"""
diff --git a/docs/narr/MyProject/myproject/tests.py b/docs/narr/MyProject/myproject/tests.py
index d8b764041..64dcab1d5 100644
--- a/docs/narr/MyProject/myproject/tests.py
+++ b/docs/narr/MyProject/myproject/tests.py
@@ -2,6 +2,7 @@ import unittest
from pyramid import testing
+
class ViewTests(unittest.TestCase):
def setUp(self):
self.config = testing.setUp()
diff --git a/docs/narr/MyProject/myproject/views.py b/docs/narr/MyProject/myproject/views.py
index f571a5976..c383c5716 100644
--- a/docs/narr/MyProject/myproject/views.py
+++ b/docs/narr/MyProject/myproject/views.py
@@ -1,5 +1,6 @@
from pyramid.view import view_config
+
@view_config(route_name='home', renderer='templates/mytemplate.pt')
def my_view(request):
- return {'project':'MyProject'}
+ return {'project': 'MyProject'}
diff --git a/docs/narr/MyProject/setup.py b/docs/narr/MyProject/setup.py
index b119a954b..f24b6984e 100644
--- a/docs/narr/MyProject/setup.py
+++ b/docs/narr/MyProject/setup.py
@@ -15,10 +15,10 @@ requires = [
setup(name='MyProject',
version='0.0',
description='MyProject',
- long_description=README + '\n\n' + CHANGES,
+ long_description=README + '\n\n' + CHANGES,
classifiers=[
"Programming Language :: Python",
- "Framework :: Pylons",
+ "Framework :: Pyramid",
"Topic :: Internet :: WWW/HTTP",
"Topic :: Internet :: WWW/HTTP :: WSGI :: Application",
],
@@ -32,7 +32,7 @@ setup(name='MyProject',
install_requires=requires,
tests_require=requires,
test_suite="myproject",
- entry_points = """\
+ entry_points="""\
[paste.app_factory]
main = myproject:main
""",
diff --git a/docs/narr/advconfig.rst b/docs/narr/advconfig.rst
index ad22a82c9..ba43f3ea6 100644
--- a/docs/narr/advconfig.rst
+++ b/docs/narr/advconfig.rst
@@ -417,7 +417,7 @@ added in configuration execution order.
More Information
----------------
-For more information, see the article entitled `"A Whirlwind Rour of Advanced
+For more information, see the article,`"A Whirlwind Tour of Advanced
Configuration Tactics"
-<http://docs.pylonsproject.org/projects/pyramid_cookbook/en/latest/configuration/whirlwind_tour.html>`_
+<http://docs.pylonsproject.org/projects/pyramid_cookbook/en/latest/configuration/whirlwind_tour.html>`_,
in the Pyramid Cookbook.
diff --git a/docs/narr/assets.rst b/docs/narr/assets.rst
index e8e915297..7b620548d 100644
--- a/docs/narr/assets.rst
+++ b/docs/narr/assets.rst
@@ -252,7 +252,7 @@ static assets that live *outside* the :app:`Pyramid` application. This will
happen when the :meth:`~pyramid.config.Configurator.add_static_view` API
associated with the path fed to :meth:`~pyramid.request.Request.static_url`
is a *URL* instead of a view name. For example, the ``name`` argument may be
-``http://example.com`` while the the ``path`` given may be
+``http://example.com`` while the ``path`` given may be
``mypackage:images``:
.. code-block:: python
diff --git a/docs/narr/commandline.rst b/docs/narr/commandline.rst
index 3bdf8c5cd..8e360216d 100644
--- a/docs/narr/commandline.rst
+++ b/docs/narr/commandline.rst
@@ -504,7 +504,8 @@ environment much like the environment produced when a particular
using the :func:`pyramid.paster.bootstrap` command in the body of your
script.
-.. note:: This feature is new as of :app:`Pyramid` 1.1.
+.. versionadded:: 1.1
+ This feature.
In the simplest case, :func:`pyramid.paster.bootstrap` can be used with a
single argument, which accepts the :term:`PasteDeploy` ``.ini`` file
@@ -758,7 +759,7 @@ we'll pretend you have a distribution with a package in it named
This script uses the Python ``optparse`` module to allow us to make sense out
of extra arguments passed to the script. It uses the
-:func:`pyramid.paster.bootstrap` function to get information about the the
+:func:`pyramid.paster.bootstrap` function to get information about the
application defined by a config file, and prints the deployment settings
defined in that config file.
diff --git a/docs/narr/configuration.rst b/docs/narr/configuration.rst
index cd3dab099..6f82baf32 100644
--- a/docs/narr/configuration.rst
+++ b/docs/narr/configuration.rst
@@ -101,27 +101,25 @@ for decorations happens when the :meth:`pyramid.config.Configurator.scan`
method is invoked: scanning implies searching for configuration declarations
in a package and its subpackages. For example:
-.. topic:: Starting A Scan
-
- .. code-block:: python
- :linenos:
-
- from wsgiref.simple_server import make_server
- from pyramid.config import Configurator
- from pyramid.response import Response
- from pyramid.view import view_config
-
- @view_config()
- def hello(request):
- return Response('Hello')
-
- if __name__ == '__main__':
- from pyramid.config import Configurator
- config = Configurator()
- config.scan()
- app = config.make_wsgi_app()
- server = make_server('0.0.0.0', 8080, app)
- server.serve_forever()
+.. code-block:: python
+ :linenos:
+
+ from wsgiref.simple_server import make_server
+ from pyramid.config import Configurator
+ from pyramid.response import Response
+ from pyramid.view import view_config
+
+ @view_config()
+ def hello(request):
+ return Response('Hello')
+
+ if __name__ == '__main__':
+ from pyramid.config import Configurator
+ config = Configurator()
+ config.scan()
+ app = config.make_wsgi_app()
+ server = make_server('0.0.0.0', 8080, app)
+ server.serve_forever()
The scanning machinery imports each module and subpackage in a package or
module recursively, looking for special attributes attached to objects
@@ -144,7 +142,6 @@ In the example above, the scanner translates the arguments to
.. ignore-next-block
.. code-block:: python
- :linenos:
config.add_view(hello)
diff --git a/docs/narr/environment.rst b/docs/narr/environment.rst
index 8206e0bcb..281bb6919 100644
--- a/docs/narr/environment.rst
+++ b/docs/narr/environment.rst
@@ -203,7 +203,7 @@ Using the setting is equivalent to using the
| |
+---------------------------------+
-The value supplied as ``pyramid.includes`` should be a sequence. The
+The value assigned to ``pyramid.includes`` should be a sequence. The
sequence can take several different forms.
1) It can be a string.
@@ -323,7 +323,7 @@ the behest of an add-on author.
| |
+---------------------------------+
-The value supplied as ``pyramid.tweens`` should be a sequence. The
+The value assigned to ``pyramid.tweens`` should be a sequence. The
sequence can take several different forms.
1) It can be a string.
@@ -504,12 +504,13 @@ default, this is ``false``.
Mako Preprocessor
~~~~~~~~~~~~~~~~~
+.. versionadded:: 1.1
+
A callable (or a :term:`dotted Python name` which names a callable) which is
called to preprocess the source before the template is called. The callable
will be passed the full template source before it is parsed. The return
result of the callable will be used as the template source code.
-.. note:: This feature is new in Pyramid 1.1.
+-----------------------------+
| Config File Setting Name |
diff --git a/docs/narr/extconfig.rst b/docs/narr/extconfig.rst
index 5e7fe2753..f33326279 100644
--- a/docs/narr/extconfig.rst
+++ b/docs/narr/extconfig.rst
@@ -227,9 +227,7 @@ augment Pyramid's configuration introspection system.
Adding Configuration Introspection
----------------------------------
-.. note::
-
- The introspection subsystem is new in Pyramid 1.3.
+.. versionadded:: 1.3
Pyramid provides a configuration introspection system that can be used by
debugging tools to provide visibility into the configuration of a running
@@ -289,7 +287,7 @@ The ``title`` is a human-consumable string that can be used by introspection
system frontends to show a friendly summary of this introspectable.
The ``type_name`` is a value that can be used to subtype this introspectable
-within its category for for sorting and presentation purposes. It can be any
+within its category for sorting and presentation purposes. It can be any
value.
An introspectable is also dictionary-like. It can contain any set of
diff --git a/docs/narr/extending.rst b/docs/narr/extending.rst
index c464203f0..dd9281c73 100644
--- a/docs/narr/extending.rst
+++ b/docs/narr/extending.rst
@@ -84,7 +84,7 @@ function in your application's ``__init__.py``. For example, rather than:
config.add_view('myapp.views.view1', name='view1')
config.add_view('myapp.views.view2', name='view2')
-You should do move the calls to ``add_view`` outside of the (non-reusable)
+You should move the calls to ``add_view`` outside of the (non-reusable)
``if __name__ == '__main__'`` block, and into a reusable function:
.. code-block:: python
diff --git a/docs/narr/firstapp.rst b/docs/narr/firstapp.rst
index ccaa6e9e2..d61d95685 100644
--- a/docs/narr/firstapp.rst
+++ b/docs/narr/firstapp.rst
@@ -40,7 +40,7 @@ On Windows:
This command will not return and nothing will be printed to the console.
When port 8080 is visited by a browser on the URL ``/hello/world``, the
server will simply serve up the text "Hello world!". If your application is
-running on your local system, using ``http://localhost:8080/hello/world``
+running on your local system, using `<http://localhost:8080/hello/world>`_
in a browser will show this result.
Each time you visit a URL served by the application in a browser, a logging
@@ -194,13 +194,13 @@ WSGI Application Creation
After configuring views and ending configuration, the script creates a WSGI
*application* via the :meth:`pyramid.config.Configurator.make_wsgi_app`
method. A call to ``make_wsgi_app`` implies that all configuration is
-finished (meaning all method calls to the configurator which set up views,
-and various other configuration settings have been performed). The
+finished (meaning all method calls to the configurator, which sets up views
+and various other configuration settings, have been performed). The
``make_wsgi_app`` method returns a :term:`WSGI` application object that can
be used by any WSGI server to present an application to a requestor.
:term:`WSGI` is a protocol that allows servers to talk to Python
applications. We don't discuss :term:`WSGI` in any depth within this book,
-however, you can learn more about it by visiting `wsgi.org
+but you can learn more about it by visiting `wsgi.org
<http://wsgi.org>`_.
The :app:`Pyramid` application object, in particular, is an instance of a
@@ -228,7 +228,7 @@ listens only on the ``127.0.0.1`` interface, which is problematic if you're
running the server on a remote system and you wish to access it with a web
browser from a local system. We also specify a TCP port number to listen on,
which is 8080, passing it as the second argument. The final argument is the
-``app`` object (a :term:`router`), which is the the application we wish to
+``app`` object (a :term:`router`), which is the application we wish to
serve. Finally, we call the server's ``serve_forever`` method, which starts
the main loop in which it will wait for requests from the outside world.
diff --git a/docs/narr/hooks.rst b/docs/narr/hooks.rst
index ea75e5fe4..fc5c0ff23 100644
--- a/docs/narr/hooks.rst
+++ b/docs/narr/hooks.rst
@@ -336,9 +336,9 @@ when adding renderer global values exists in :ref:`adding_renderer_globals`.
Adding Renderer Globals (Deprecated)
------------------------------------
-.. warning:: this feature is deprecated as of Pyramid 1.1. A non-deprecated
- mechanism which allows event subscribers to add renderer global values
- is documented in :ref:`beforerender_event`.
+.. deprecated:: 1.1
+ An alternative mechanism which allows event subscribers to add renderer
+ global values is documented in :ref:`beforerender_event`.
Whenever :app:`Pyramid` handles a request to perform a rendering (after a
view with a ``renderer=`` configuration attribute is invoked, or when any of
@@ -635,13 +635,13 @@ See :meth:`pyramid.config.add_resource_url_adapter` for more information.
Changing How Pyramid Treats View Responses
------------------------------------------
+.. versionadded:: 1.1
+
It is possible to control how Pyramid treats the result of calling a view
callable on a per-type basis by using a hook involving
:meth:`pyramid.config.Configurator.add_response_adapter` or the
:class:`~pyramid.response.response_adapter` decorator.
-.. note:: This feature is new as of Pyramid 1.1.
-
Pyramid, in various places, adapts the result of calling a view callable to
the :class:`~pyramid.interfaces.IResponse` interface to ensure that the
object returned by the view callable is a "true" response object. The vast
@@ -936,8 +936,8 @@ For full details, please read the `Venusian documentation
Registering "Tweens"
--------------------
-.. note:: Tweens are a feature which were added in Pyramid 1.2. They are
- not available in any previous version.
+.. versionadded:: 1.2
+ Tweens
A :term:`tween` (a contraction of the word "between") is a bit of code that
sits between the Pyramid router's main request handling function and the
@@ -1082,7 +1082,7 @@ entirely by the relative ordering of calls to
:meth:`pyramid.config.Configurator.add_tween`. However, the caller of
add_tween can provide an optional hint that can influence the implicit tween
chain ordering by supplying ``under`` or ``over`` (or both) arguments to
-:meth:`~pyramid.config.Configurator.add_tween`. These hints are only used
+:meth:`~pyramid.config.Configurator.add_tween`. These hints are only
used when an explicit tween ordering is not used. See
:ref:`explicit_tween_ordering` for a description of how to set an explicit
tween ordering.
@@ -1241,10 +1241,7 @@ implict and explicit tween chains used by an application. See
Adding A Third Party View, Route, or Subscriber Predicate
---------------------------------------------------------
-.. note::
-
- Third-party view, route, and subscriber predicates are a feature new as of
- Pyramid 1.4.
+.. versionadded:: 1.4
.. _view_and_route_predicates:
diff --git a/docs/narr/hybrid.rst b/docs/narr/hybrid.rst
index ab1bf20bb..1773a6b8c 100644
--- a/docs/narr/hybrid.rst
+++ b/docs/narr/hybrid.rst
@@ -477,7 +477,7 @@ Registering a Default View for a Route That Has a ``view`` Attribute
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. warning:: As of :app:`Pyramid` 1.1 this section is slated to be removed in
- a later documentation release because the the ability to add views
+ a later documentation release because the ability to add views
directly to the :term:`route configuration` by passing a ``view`` argument
to ``add_route`` has been deprecated.
diff --git a/docs/narr/i18n.rst b/docs/narr/i18n.rst
index e261f9a11..511464322 100644
--- a/docs/narr/i18n.rst
+++ b/docs/narr/i18n.rst
@@ -301,7 +301,7 @@ You need to add a few boilerplate lines to your application's ``setup.py``
file in order to properly generate :term:`gettext` files from your
application.
-.. note:: See :ref:`project_narr` to learn about about the
+.. note:: See :ref:`project_narr` to learn about the
composition of an application's ``setup.py`` file.
In particular, add the ``Babel`` and ``lingua`` distributions to the
diff --git a/docs/narr/install.rst b/docs/narr/install.rst
index e8482a289..b092f73bc 100644
--- a/docs/narr/install.rst
+++ b/docs/narr/install.rst
@@ -14,8 +14,8 @@ run :app:`Pyramid`.
.. sidebar:: Python Versions
- As of this writing, :app:`Pyramid` has been tested under Python 2.6.8,
- Python 2.7.3, Python 3.2.3, and Python 3.3b1. :app:`Pyramid` does not
+ As of this writing, :app:`Pyramid` has been tested under Python 2.6,
+ Python 2.7, Python 3.2, and Python 3.3. :app:`Pyramid` does not
run under any version of Python before 2.6.
:app:`Pyramid` is known to run on all popular UNIX-like systems such as
@@ -40,18 +40,20 @@ UNIX system that has development tools.
Package Manager Method
++++++++++++++++++++++
-You can use your system's "package manager" to install Python. Every
-system's package manager is slightly different, but the "flavor" of
+You can use your system's "package manager" to install Python.
+Each package manager is slightly different, but the "flavor" of
them is usually the same.
-For example, on an Ubuntu Linux system, to use the system package
-manager to install a Python 2.7 interpreter, use the following
-command:
+For example, on a Debian or Ubuntu system, use the following command:
.. code-block:: text
$ sudo apt-get install python2.7-dev
+This command will install both the Python interpreter and its development
+header files. Note that the headers are required by some (optional) C
+extensions in software depended upon by Pyramid, not by Pyramid itself.
+
Once these steps are performed, the Python interpreter will usually be
invokable via ``python2.7`` from a shell prompt.
@@ -66,7 +68,8 @@ Python interpreter to develop your software. The authors of
:app:`Pyramid` tend not to use the system Python for development
purposes; always a self-compiled one. Compiling Python is usually
easy, and often the "system" Python is compiled with options that
-aren't optimal for web development.
+aren't optimal for web development. For an explanation, see
+https://github.com/Pylons/pyramid/issues/747.
To compile software on your UNIX system, typically you need
development tools. Often these can be installed via the package
@@ -85,17 +88,15 @@ using the following commands:
.. code-block:: text
- [chrism@vitaminf ~]$ cd ~
- [chrism@vitaminf ~]$ mkdir tmp
- [chrism@vitaminf ~]$ mkdir opt
- [chrism@vitaminf ~]$ cd tmp
- [chrism@vitaminf tmp]$ wget \
- http://www.python.org/ftp/python/2.7.3/Python-2.7.3.tgz
- [chrism@vitaminf tmp]$ tar xvzf Python-2.7.3.tgz
- [chrism@vitaminf tmp]$ cd Python-2.7.3
- [chrism@vitaminf Python-2.7.3]$ ./configure \
- --prefix=$HOME/opt/Python-2.7.3
- [chrism@vitaminf Python-2.7.3]$ make; make install
+ $ cd ~
+ $ mkdir tmp
+ $ mkdir opt
+ $ cd tmp
+ $ wget http://www.python.org/ftp/python/2.7.3/Python-2.7.3.tgz
+ $ tar xvzf Python-2.7.3.tgz
+ $ cd Python-2.7.3
+ $ ./configure --prefix=$HOME/opt/Python-2.7.3
+ $ make && make install
Once these steps are performed, the Python interpreter will be
invokable via ``$HOME/opt/Python-2.7.3/bin/python`` from a shell
@@ -146,37 +147,24 @@ To set up a virtualenv in which to install :app:`Pyramid`, first ensure that
``import setuptools`` within the Python interpreter you'd like to run
:app:`Pyramid` under.
-Here's the output you'll expect if setuptools or distribute is already
-installed:
+The following command will not display anything if setuptools or distribute is
+already installed:
.. code-block:: text
- [chrism@thinko docs]$ python2.7
- Python 2.7.3 (default, Aug 1 2012, 05:14:39)
- [GCC 4.6.3] on linux2
- Type "help", "copyright", "credits" or "license" for more information.
- >>> import setuptools
- >>>
+ $ python2.7 -c 'import setuptools'
-Here's the output you can expect if setuptools or distribute is not already
-installed:
+Running the same command will yield the following output if setuptools or
+distribute is not yet installed:
.. code-block:: text
- [chrism@thinko docs]$ python2.7
- Python 2.7.3 (default, Aug 1 2012, 05:14:39)
- [GCC 4.6.3] on linux2
- Type "help", "copyright", "credits" or "license" for more information.
- >>> import setutptools
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
- ImportError: No module named setutptools
- >>>
+ ImportError: No module named setuptools
If ``import setuptools`` raises an :exc:`ImportError` as it does above, you
-will need to install setuptools or distribute manually. Note that above
-we're using a Python 2.7-series interpreter on Mac OS X; your output may
-differ if you're using a later Python version or a different platform.
+will need to install setuptools or distribute manually.
If you are using a "system" Python (one installed by your OS distributor or a
3rd-party packager such as Fink or MacPorts), you can usually install the
@@ -243,6 +231,20 @@ Once you've got setuptools or distribute installed, you should install the
:term:`virtualenv` package. To install the :term:`virtualenv` package into
your setuptools-enabled Python interpreter, use the ``easy_install`` command.
+.. warning::
+
+ Python 3.3 includes ``pyvenv`` out of the box, which provides similar
+ functionality to ``virtualenv``. We however suggest using ``virtualenv``
+ instead, which works well with Python 3.3. This isn't a recommendation made
+ for technical reasons; it's made because it's not feasible for the authors
+ of this guide to explain setup using multiple virtual environment systems.
+ We are aiming to not need to make the installation documentation
+ Turing-complete.
+
+ If you insist on using ``pyvenv``, you'll need to understand how to install
+ software such as ``distribute`` into the virtual environment manually,
+ which this guide does not cover.
+
.. code-block:: text
$ easy_install virtualenv
diff --git a/docs/narr/introduction.rst b/docs/narr/introduction.rst
index b35c61720..3540ee5c4 100644
--- a/docs/narr/introduction.rst
+++ b/docs/narr/introduction.rst
@@ -101,7 +101,7 @@ frameworks for small and large applications is just false; a well-designed
framework should be able to be good at both. Pyramid strives to be that kind
of framework.
-To this end, Pyramid provides a set of features, that, combined, are unique
+To this end, Pyramid provides a set of features that, combined, are unique
amongst Python web frameworks. Lots of other frameworks contain some
combination of these features; Pyramid of course actually stole many of them
from those other frameworks. But Pyramid is the only one that has all of
@@ -475,7 +475,7 @@ per route. For example, you can create a route with the pattern ``/items``
and when the route is matched, you can shuffle off the request to one view if
the request method is GET, another view if the request method is POST, etc.
A system known as "view predicates" allows for this. Request method matching
-is the very most basic thing you can do with a view predicate. You can also
+is the most basic thing you can do with a view predicate. You can also
associate views with other request parameters such as the elements in the
query string, the Accept header, whether the request is an XHR request or
not, and lots of other things. This feature allows you to keep your
@@ -749,7 +749,7 @@ that we change Pyramid? You can extend Pyramid's :term:`Configurator` with
your own directives. For example, let's say you find yourself calling
:meth:`pyramid.config.Configurator.add_view` repetitively. Usually you can
take the boring away by using existing shortcuts, but let's say that this is
-a case such a way that no existing shortcut works to take the boring away:
+a case where there is no such shortcut:
.. code-block:: python
:linenos:
diff --git a/docs/narr/introspector.rst b/docs/narr/introspector.rst
index b88f3f0c8..7784e8960 100644
--- a/docs/narr/introspector.rst
+++ b/docs/narr/introspector.rst
@@ -130,6 +130,23 @@ introspectables in categories not described here.
A sequence of interfaces (or classes) that are subscribed to (the
resolution of the ``ifaces`` argument passed to ``add_subscriber``).
+ ``derived_subscriber``
+
+ A wrapper around the subscriber used internally by the system so it can
+ call it with more than one argument if your original subscriber accepts
+ only one.
+
+ ``predicates``
+
+ The predicate objects created as the result of passing predicate arguments
+ to ``add_susbcriber``
+
+ ``derived_predicates``
+
+ Wrappers around the predicate objects created as the result of passing
+ predicate arguments to ``add_susbcriber`` (to be used when predicates take
+ only one value but must be passed more than one).
+
``response adapters``
Each introspectable in the ``response adapters`` category represents a call
@@ -479,7 +496,7 @@ introspectables in categories not described here.
``translation directories``
Each introspectable in the ``asset overrides`` category represents an
- individual element in a ``specs`` argument passed to to
+ individual element in a ``specs`` argument passed to
:meth:`pyramid.config.Configurator.add_translation_dirs`; each will have
the following data.
diff --git a/docs/narr/project.rst b/docs/narr/project.rst
index b08948e43..5a8ea0ecf 100644
--- a/docs/narr/project.rst
+++ b/docs/narr/project.rst
@@ -297,7 +297,7 @@ For example, your system might be configured to have an external IP address
``192.168.1.50``. If that's the case, if you use a browser running on the
same system as Pyramid, it will be able to access the application via
``http://127.0.0.1:6543/`` as well as via
-``http://129.168.1.50:6543/``. However, *other people* on other computers on
+``http://192.168.1.50:6543/``. However, *other people* on other computers on
the same network will also be able to visit your Pyramid application in their
browser by visiting ``http://192.168.1.50:6543/``.
@@ -829,25 +829,25 @@ also informs Python that the directory which contains it is a *package*.
#. Line 1 imports the :term:`Configurator` class from :mod:`pyramid.config`
that we use later.
-#. Lines 3-10 define a function named ``main`` that returns a :app:`Pyramid`
+#. Lines 4-11 define a function named ``main`` that returns a :app:`Pyramid`
WSGI application. This function is meant to be called by the
:term:`PasteDeploy` framework as a result of running ``pserve``.
Within this function, application configuration is performed.
- Line 6 creates an instance of a :term:`Configurator`.
+ Line 7 creates an instance of a :term:`Configurator`.
- Line 7 registers a static view, which will serve up the files from the
+ Line 8 registers a static view, which will serve up the files from the
``myproject:static`` :term:`asset specification` (the ``static``
directory of the ``myproject`` package).
- Line 8 adds a :term:`route` to the configuration. This route is later
+ Line 9 adds a :term:`route` to the configuration. This route is later
used by a view in the ``views`` module.
- Line 9 calls ``config.scan()``, which picks up view registrations declared
+ Line 10 calls ``config.scan()``, which picks up view registrations declared
elsewhere in the package (in this case, in the ``views.py`` module).
- Line 10 returns a :term:`WSGI` application to the caller of the function
+ Line 11 returns a :term:`WSGI` application to the caller of the function
(Pyramid's pserve).
.. index::
@@ -865,7 +865,7 @@ and which returns a :term:`response`.
:language: python
:linenos:
-Lines 3-5 define and register a :term:`view callable` named ``my_view``. The
+Lines 4-6 define and register a :term:`view callable` named ``my_view``. The
function named ``my_view`` is decorated with a ``view_config`` decorator
(which is processed by the ``config.scan()`` line in our ``__init__.py``).
The view_config decorator asserts that this view be found when a
diff --git a/docs/narr/renderers.rst b/docs/narr/renderers.rst
index 1158d2225..863932e83 100644
--- a/docs/narr/renderers.rst
+++ b/docs/narr/renderers.rst
@@ -63,7 +63,6 @@ the ``renderer`` attribute. For example, this call to
with a view callable:
.. code-block:: python
- :linenos:
config.add_view('myproject.views.my_view', renderer='json')
@@ -73,13 +72,13 @@ which renders view return values to a :term:`JSON` response serialization.
Other built-in renderers include renderers which use the :term:`Chameleon`
templating language to render a dictionary to a response. Additional
-renderers can be added by developers to the system as necessary (see
-:ref:`adding_and_overriding_renderers`).
+renderers can be added by developers to the system as necessary.
+See :ref:`adding_and_overriding_renderers`.
Views which use a renderer and return a non-Response value can vary non-body
response attributes (such as headers and the HTTP status code) by attaching a
-property to the ``request.response`` attribute See
-:ref:`request_response_attr`.
+property to the ``request.response`` attribute.
+See :ref:`request_response_attr`.
If the :term:`view callable` associated with a :term:`view configuration`
returns a Response object directly, any renderer associated with the view
@@ -166,7 +165,6 @@ The body of the response returned by such a view will be a string
representing the ``str()`` serialization of the return value:
.. code-block:: python
- :linenos:
{'content': 'Hello!'}
@@ -204,7 +202,6 @@ The body of the response returned by such a view will be a string
representing the JSON serialization of the return value:
.. code-block:: python
- :linenos:
'{"content": "Hello!"}'
@@ -264,7 +261,7 @@ will be the active request object at render time.
# [{"x": 1}, {"x": 2}]
If you aren't the author of the objects being serialized, it won't be
-possible (or at least not reasonable) to add a custom ``__json__`` method to
+possible (or at least not reasonable) to add a custom ``__json__`` method
to their classes in order to influence serialization. If the object passed
to the renderer is not a serializable type, and has no ``__json__`` method,
usually a :exc:`TypeError` will be raised during serialization. You can
@@ -294,9 +291,8 @@ with the object.
See :class:`pyramid.renderers.JSON` and
:ref:`adding_and_overriding_renderers` for more information.
-.. note::
-
- Serializing custom objects is a feature new in Pyramid 1.4.
+.. versionadded:: 1.4
+ Serializing custom objects.
.. index::
pair: renderer; JSONP
@@ -306,9 +302,7 @@ See :class:`pyramid.renderers.JSON` and
JSONP Renderer
~~~~~~~~~~~~~~
-.. note::
-
- This feature is new in Pyramid 1.1.
+.. versionadded:: 1.1
:class:`pyramid.renderers.JSONP` is a `JSONP
<http://en.wikipedia.org/wiki/JSONP>`_ renderer factory helper which
@@ -366,7 +360,7 @@ For example (Javascript):
'&callback=?';
jqhxr = $.getJSON(api_url);
-The string ``callback=?`` above in the the ``url`` param to the JQuery
+The string ``callback=?`` above in the ``url`` param to the JQuery
``getAjax`` function indicates to jQuery that the query should be made as
a JSONP request; the ``callback`` parameter will be automatically filled
in for you and used.
@@ -571,7 +565,8 @@ in :ref:`request_module`. For more information on the API of
Deprecated Mechanism to Vary Attributes of Rendered Responses
-------------------------------------------------------------
-.. warning:: This section describes behavior deprecated in Pyramid 1.1.
+.. deprecated:: 1.1
+ The behavior described in this entire section.
In previous releases of Pyramid (1.0 and before), the ``request.response``
attribute did not exist. Instead, Pyramid required users to set special
@@ -619,7 +614,6 @@ For example, to add a renderer which renders views which have a
``renderer`` attribute that is a path that ends in ``.jinja2``:
.. code-block:: python
- :linenos:
config.add_renderer('.jinja2', 'mypackage.MyJinja2Renderer')
@@ -689,12 +683,10 @@ There are essentially two different kinds of renderer factories:
:term:`package`.
Here's an example of the registration of a simple renderer factory via
-:meth:`~pyramid.config.Configurator.add_renderer`:
+:meth:`~pyramid.config.Configurator.add_renderer`, where ``config``
+is an instance of :meth:`pyramid.config.Configurator`:
.. code-block:: python
- :linenos:
-
- # config is an instance of pyramid.config.Configurator
config.add_renderer(name='amf', factory='my.package.MyAMFRenderer')
@@ -725,10 +717,8 @@ Here's an example of the registration of a more complicated renderer
factory, which expects to be passed a filesystem path:
.. code-block:: python
- :linenos:
- config.add_renderer(name='.jinja2',
- factory='my.package.MyJinja2Renderer')
+ config.add_renderer(name='.jinja2', factory='my.package.MyJinja2Renderer')
Adding the above code to your application startup will allow you to use the
``my.package.MyJinja2Renderer`` renderer factory implementation in view
@@ -769,7 +759,6 @@ extension for the same kinds of templates. For example, to associate the
:meth:`pyramid.config.Configurator.add_renderer` method:
.. code-block:: python
- :linenos:
config.add_renderer('.zpt', 'pyramid.chameleon_zpt.renderer_factory')
@@ -781,7 +770,6 @@ rendered via a Chameleon ZPT page template renderer, use a variation on the
following in your application's startup code:
.. code-block:: python
- :linenos:
config.add_renderer('.pt', 'mypackage.pt_renderer')
@@ -794,7 +782,6 @@ ones which do not possess a ``renderer`` attribute), pass ``None`` as
the ``name`` attribute to the renderer tag:
.. code-block:: python
- :linenos:
config.add_renderer(None, 'mypackage.json_renderer_factory')
@@ -823,8 +810,8 @@ sets an ``override_renderer`` attribute on the request itself, which is the
.. code-block:: python
:linenos:
- from pyramid.event import subscriber
- from pyramid.event import NewRequest
+ from pyramid.events import subscriber
+ from pyramid.events import NewRequest
@subscriber(NewRequest)
def set_xmlrpc_params(event):
diff --git a/docs/narr/sessions.rst b/docs/narr/sessions.rst
index f7da7838e..fa4affd8a 100644
--- a/docs/narr/sessions.rst
+++ b/docs/narr/sessions.rst
@@ -29,7 +29,7 @@ during your :app:`Pyramid` configuration.
A very basic, insecure sample session factory implementation is
provided in the :app:`Pyramid` core. It uses a cookie to store
session information. This implementation has the following
-limitation:
+limitations:
- The session information in the cookies used by this implementation
is *not* encrypted, so it can be viewed by anyone with access to the
diff --git a/docs/narr/subrequest.rst b/docs/narr/subrequest.rst
index 89551ab35..b5bc5ec48 100644
--- a/docs/narr/subrequest.rst
+++ b/docs/narr/subrequest.rst
@@ -142,7 +142,7 @@ generated. We can change this behavior; how to do so is described below in
our discussion of the ``use_tweens`` argument.
The :meth:`pyramid.request.Request.invoke_subrequest` API accepts two
-arguments: a positional argument ``request`` that must be provided, and and
+arguments: a positional argument ``request`` that must be provided, and
``use_tweens`` keyword argument that is optional; it defaults to ``False``.
The ``request`` object passed to the API must be an object that implements
diff --git a/docs/narr/templates.rst b/docs/narr/templates.rst
index ba72ebfbf..6a1fbf916 100644
--- a/docs/narr/templates.rst
+++ b/docs/narr/templates.rst
@@ -109,7 +109,7 @@ supply the renderer with more correct system values (see
to compose proper system values is present in the request. If your
template relies on the name ``request`` or ``context``, or if you've
configured special :term:`renderer globals`, make sure to pass
-``request`` as a keyword argument in every call to to a
+``request`` as a keyword argument in every call to a
``pyramid.renderers.render_*`` function.
Every view must return a :term:`response` object, except for views
@@ -543,9 +543,7 @@ template as a :term:`renderer` like so:
The above will render only the ``bar`` macro defined within the ``foo.pt``
template instead of the entire template.
-.. note::
-
- This feature is new in Pyramid 1.4.
+.. versionadded:: 1.4
.. index::
single: Chameleon text templates
@@ -743,9 +741,7 @@ configure the template as a :term:`renderer` like so:
The above will render the ``bar`` def from within the ``foo.mak`` template
instead of the entire template.
-.. note::
-
- This feature is new in Pyramid 1.4.
+.. versionadded:: 1.4
.. index::
single: automatic reloading of templates
diff --git a/docs/narr/upgrading.rst b/docs/narr/upgrading.rst
index 839f59c35..20487b448 100644
--- a/docs/narr/upgrading.rst
+++ b/docs/narr/upgrading.rst
@@ -206,7 +206,7 @@ information.
Upgrading to the Very Latest Pyramid Release
--------------------------------------------
-When you upgrade your application to the very most recent Pyramid release,
+When you upgrade your application to the most recent Pyramid release,
it's advisable to upgrade step-wise through each most recent minor release,
beginning with the one that you know your application currently runs under,
and ending on the most recent release. For example, if your application is
diff --git a/docs/narr/urldispatch.rst b/docs/narr/urldispatch.rst
index ecf3d026a..749a2d49a 100644
--- a/docs/narr/urldispatch.rst
+++ b/docs/narr/urldispatch.rst
@@ -38,7 +38,7 @@ application. A route has a *name*, which acts as an identifier to be used
for URL generation. The name also allows developers to associate a view
configuration with the route. A route also has a *pattern*, meant to match
against the ``PATH_INFO`` portion of a URL (the portion following the scheme
-and port, e.g. ``/foo/bar`` in the URL ``http://localhost:8080/foo/bar``). It
+and port, e.g. ``/foo/bar`` in the URL `<http://localhost:8080/foo/bar>`_). It
also optionally has a ``factory`` and a set of :term:`route predicate`
attributes.
@@ -86,8 +86,8 @@ setup code. However, the above :term:`scan` execution
``config.scan('mypackage')`` will pick up all :term:`configuration
decoration`, including any objects decorated with the
:class:`pyramid.view.view_config` decorator in the ``mypackage`` Python
-pakage. For example, if you have a ``views.py`` in your package, a scan will
-pick up any of its configuration decorators, so we can add one there that
+package. For example, if you have a ``views.py`` in your package, a scan will
+pick up any of its configuration decorators, so we can add one there
that references ``myroute`` as a ``route_name`` parameter:
.. code-block:: python
@@ -758,11 +758,8 @@ other non-``name`` and non-``pattern`` arguments to
exception to this rule is use of the ``pregenerator`` argument, which is not
ignored when ``static`` is ``True``.
-.. note::
-
- the ``static`` argument to
- :meth:`~pyramid.config.Configurator.add_route` is new as of :app:`Pyramid`
- 1.1.
+.. versionadded:: 1.1
+ the ``static`` argument to :meth:`~pyramid.config.Configurator.add_route`
.. index::
single: redirecting to slash-appended routes
@@ -860,7 +857,7 @@ exactly the same job:
request into a ``GET``, losing any ``POST`` data in the original
request.
-See :ref:`view_module` and :ref:`changing_the_notfound_view` for for a more
+See :ref:`view_module` and :ref:`changing_the_notfound_view` for a more
general description of how to configure a view and/or a not found view.
.. index::
@@ -906,7 +903,7 @@ routes configured in your application; for more information, see
Using a Route Prefix to Compose Applications
--------------------------------------------
-.. note:: This feature is new as of :app:`Pyramid` 1.2.
+.. versionadded:: 1.2
The :meth:`pyramid.config.Configurator.include` method allows configuration
statements to be included from separate files. See
diff --git a/docs/narr/viewconfig.rst b/docs/narr/viewconfig.rst
index 6373a8d26..7001cd980 100644
--- a/docs/narr/viewconfig.rst
+++ b/docs/narr/viewconfig.rst
@@ -306,7 +306,7 @@ configured view.
consideration of keys and values in the ``request.params`` dictionary.
``match_param``
- .. note:: This feature is new as of :app:`Pyramid` 1.2.
+ .. versionadded:: 1.2
This param may be either a single string of the format "key=value" or a
dict of key/value pairs.
@@ -724,9 +724,7 @@ configuration to take effect.
``@view_defaults`` Class Decorator
----------------------------------
-.. note::
-
- This feature is new in Pyramid 1.3.
+.. versionadded:: 1.3
If you use a class as a view, you can use the
:class:`pyramid.view.view_defaults` class decorator on the class to provide
@@ -834,7 +832,7 @@ decorator on the RESTView class:
.. code-block:: python
:linenos:
- from pyramid.view import view_config
+ from pyramid.view import view_defaults
from pyramid.response import Response
from pyramid.config import Configurator
@@ -952,7 +950,7 @@ for more information about how, and where to set these values.
Influencing HTTP Caching
------------------------
-.. note:: This feature is new in Pyramid 1.1.
+.. versionadded:: 1.1
When a non-``None`` ``http_cache`` argument is passed to a view
configuration, Pyramid will set ``Expires`` and ``Cache-Control`` response
@@ -986,7 +984,7 @@ there's a ``should_cache`` GET or POST variable:
Note that the ``http_cache`` machinery will overwrite or add to caching
headers you set within the view itself unless you use ``prevent_auto``.
-You can also turn of the effect of ``http_cache`` entirely for the duration
+You can also turn off the effect of ``http_cache`` entirely for the duration
of a Pyramid application lifetime. To do so, set the
``PYRAMID_PREVENT_HTTP_CACHE`` environment variable or the
``pyramid.prevent_http_cache`` configuration value setting to a true value.
diff --git a/docs/narr/views.rst b/docs/narr/views.rst
index 07d018127..860c380f3 100644
--- a/docs/narr/views.rst
+++ b/docs/narr/views.rst
@@ -180,7 +180,7 @@ All classes documented in the :mod:`pyramid.httpexceptions` module documented
as inheriting from the :class:`pyramid.httpexceptions.HTTPException` are
:term:`http exception` objects. Instances of an HTTP exception object may
either be *returned* or *raised* from within view code. In either case
-(return or raise) the instance will be used as as the view's response.
+(return or raise) the instance will be used as the view's response.
For example, the :class:`pyramid.httpexceptions.HTTPUnauthorized` exception
can be raised. This will cause a response to be generated with a ``401
@@ -227,8 +227,8 @@ equivalent to ``raise HTTPUnauthorized()``. Documentation which maps each
HTTP response code to its purpose and its associated HTTP exception object is
provided within :mod:`pyramid.httpexceptions`.
-.. note:: The :func:`~pyramid.httpexceptions.exception_response` function is
- new as of Pyramid 1.1.
+.. versionadded:: 1.1
+ The :func:`~pyramid.httpexceptions.exception_response` function.
How Pyramid Uses HTTP Exceptions
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
diff --git a/docs/narr/webob.rst b/docs/narr/webob.rst
index a8c11acec..44940f9e6 100644
--- a/docs/narr/webob.rst
+++ b/docs/narr/webob.rst
@@ -251,7 +251,7 @@ API documentation for a multidict exists as
Dealing With A JSON-Encoded Request Body
++++++++++++++++++++++++++++++++++++++++
-.. note:: this feature is new as of Pyramid 1.1.
+.. versionadded:: 1.1
:attr:`pyramid.request.Request.json_body` is a property that returns a
:term:`JSON` -decoded representation of the request body. If the request
diff --git a/docs/remake b/docs/remake
index eb818289f..6552716c8 100755
--- a/docs/remake
+++ b/docs/remake
@@ -1 +1 @@
-make clean html SPHINXBUILD=../env27/bin/sphinx-build
+make clean html SPHINXBUILD=../env/bin/sphinx-build
diff --git a/docs/tutorials/wiki/authorization.rst b/docs/tutorials/wiki/authorization.rst
index 24249945a..7c8ba99bf 100644
--- a/docs/tutorials/wiki/authorization.rst
+++ b/docs/tutorials/wiki/authorization.rst
@@ -32,9 +32,6 @@ Then we will add the login and logout feature:
* Add a "Logout" link to be shown when logged in and viewing or editing a page
(``view.pt``, ``edit.pt``).
-The source code for this tutorial stage can be browsed at
-`http://github.com/Pylons/pyramid/tree/1.3-branch/docs/tutorials/wiki/src/authorization/
-<http://github.com/Pylons/pyramid/tree/1.3-branch/docs/tutorials/wiki/src/authorization/>`_.
Access Control
--------------
@@ -127,7 +124,7 @@ add these import statements:
Now add those policies to the configuration:
.. literalinclude:: src/authorization/tutorial/__init__.py
- :lines: 17-22
+ :lines: 18-23
:linenos:
:emphasize-lines: 1-3,5-6
:language: python
@@ -213,7 +210,7 @@ expire an auth ticket cookie.
Now add the ``login`` and ``logout`` views:
.. literalinclude:: src/authorization/tutorial/views.py
- :lines: 87-120
+ :lines: 82-120
:linenos:
:language: python
@@ -306,7 +303,7 @@ when we're done:
.. literalinclude:: src/authorization/tutorial/__init__.py
:linenos:
- :emphasize-lines: 4-5,8,17-19,21-22
+ :emphasize-lines: 4-5,8,18-20,22-23
:language: python
(Only the highlighted lines need to be added.)
diff --git a/docs/tutorials/wiki/background.rst b/docs/tutorials/wiki/background.rst
index ac337abd5..6bbd5026e 100644
--- a/docs/tutorials/wiki/background.rst
+++ b/docs/tutorials/wiki/background.rst
@@ -11,7 +11,7 @@ Python web framework experience.
To code along with this tutorial, the developer will need a UNIX
machine with development tools (Mac OS X with XCode, any Linux or BSD
-variant, etc) *or* a Windows system of any kind.
+variant, etc.) *or* a Windows system of any kind.
.. warning::
diff --git a/docs/tutorials/wiki/basiclayout.rst b/docs/tutorials/wiki/basiclayout.rst
index f6050f391..f9d4775ad 100644
--- a/docs/tutorials/wiki/basiclayout.rst
+++ b/docs/tutorials/wiki/basiclayout.rst
@@ -4,19 +4,16 @@ Basic Layout
The starter files generated by the ``zodb`` scaffold are basic, but
they provide a good orientation for the high-level patterns common to most
-:term:`traversal` -based :app:`Pyramid` (and :term:`ZODB` based) projects.
+:term:`traversal` -based :app:`Pyramid` (and :term:`ZODB` -based) projects.
-The source code for this tutorial stage can be browsed via
-`http://github.com/Pylons/pyramid/tree/1.3-branch/docs/tutorials/wiki/src/basiclayout/
-<http://github.com/Pylons/pyramid/tree/1.3-branch/docs/tutorials/wiki/src/basiclayout/>`_.
Application Configuration with ``__init__.py``
------------------------------------------------
A directory on disk can be turned into a Python :term:`package` by containing
an ``__init__.py`` file. Even if empty, this marks a directory as a Python
-package. Our application uses ``__init__.py`` as both a package marker, as
-well as to contain application configuration code.
+package. Our application uses ``__init__.py`` both as a package marker and
+to contain application configuration code.
When you run the application using the ``pserve`` command using the
``development.ini`` generated config file, the application configuration
@@ -31,35 +28,35 @@ point happens to be the ``main`` function within the file named
#. *Lines 1-3*. Perform some dependency imports.
-#. *Lines 5-7* Define a root factory for our Pyramid application.
+#. *Lines 6-8*. Define a root factory for our Pyramid application.
-#. *Line 12*. We construct a :term:`Configurator` with a :term:`root
+#. *Line 14*. We construct a :term:`Configurator` with a :term:`root
factory` and the settings keywords parsed by :term:`PasteDeploy`. The root
factory is named ``root_factory``.
-#. *Line 13*. Register a 'static view' which answers requests which start
- with with URL path ``/static`` using the
+#. *Line 15*. Register a "static view" which answers requests whose URL path
+ start with ``/static`` using the
:meth:`pyramid.config.Configurator.add_static_view method`. This
statement registers a view that will serve up static assets, such as CSS
and image files, for us, in this case, at
``http://localhost:6543/static/`` and below. The first argument is the
"name" ``static``, which indicates that the URL path prefix of the view
- will be ``/static``. the The second argument of this tag is the "path",
+ will be ``/static``. The second argument of this tag is the "path",
which is a relative :term:`asset specification`, so it finds the resources
it should serve within the ``static`` directory inside the ``tutorial``
- package. The scaffold could have alternately used an *absolute* asset
- specification as the path (``tutorial:static``) but it does not.
+ package. Alternatively the scaffold could have used an *absolute* asset
+ specification as the path (``tutorial:static``).
-#. *Line 14*. Perform a :term:`scan`. A scan will find :term:`configuration
- decoration`, such as view configuration decorators (e.g. ``@view_config``)
+#. *Line 16*. Perform a :term:`scan`. A scan will find :term:`configuration
+ decoration`, such as view configuration decorators (e.g., ``@view_config``)
in the source code of the ``tutorial`` package and will take actions based
on these decorators. We don't pass any arguments to
:meth:`~pyramid.config.Configurator.scan`, which implies that the scan
should take place in the current package (in this case, ``tutorial``).
- The scaffold could have equivalently said ``config.scan('tutorial')`` but
+ The scaffold could have equivalently said ``config.scan('tutorial')``, but
it chose to omit the package name argument.
-#. *Line 15*. Use the
+#. *Line 17*. Use the
:meth:`pyramid.config.Configurator.make_wsgi_app` method
to return a :term:`WSGI` application.
@@ -73,7 +70,7 @@ tree represents the site structure, but it *also* represents the
:term:`domain model` of the application, because each resource is a node
stored persistently in a :term:`ZODB` database. The ``models.py`` file is
where the ``zodb`` scaffold put the classes that implement our
-resource objects, each of which happens also to be a domain model object.
+resource objects, each of which also happens to be a domain model object.
Here is the source for ``models.py``:
@@ -81,15 +78,15 @@ Here is the source for ``models.py``:
:linenos:
:language: py
-#. *Lines 3-4*. The ``MyModel`` :term:`resource` class is implemented here.
- Instances of this class will be capable of being persisted in :term:`ZODB`
+#. *Lines 4-5*. The ``MyModel`` :term:`resource` class is implemented here.
+ Instances of this class are capable of being persisted in :term:`ZODB`
because the class inherits from the
:class:`persistent.mapping.PersistentMapping` class. The ``__parent__``
and ``__name__`` are important parts of the :term:`traversal` protocol.
By default, have these as ``None`` indicating that this is the
:term:`root` object.
-#. *Lines 6-12*. ``appmaker`` is used to return the *application
+#. *Lines 8-14*. ``appmaker`` is used to return the *application
root* object. It is called on *every request* to the
:app:`Pyramid` application. It also performs bootstrapping by
*creating* an application root (inside the ZODB root object) if one
@@ -118,7 +115,7 @@ Let's try to understand the components in this module:
#. *Lines 1-2*. Perform some dependency imports.
-#. *Line 4*. Use the :func:`pyramid.view.view_config` :term:`configuration
+#. *Line 5*. Use the :func:`pyramid.view.view_config` :term:`configuration
decoration` to perform a :term:`view configuration` registration. This
view configuration registration will be activated when the application is
started. It will be activated by virtue of it being found as the result
@@ -140,7 +137,7 @@ Let's try to understand the components in this module:
indeed if you look in the ``templates`` directory of this package, you'll
see a ``mytemplate.pt`` template file, which renders the default home page
of the generated project. This asset specification is *relative* (to the
- view.py's current package). We could have alternately an used the
+ view.py's current package). Alternatively we could have used the
absolute asset specification ``tutorial:templates/mytemplate.pt``, but
chose to use the relative version.
@@ -148,7 +145,7 @@ Let's try to understand the components in this module:
``my_view`` function which it decorates represents the "default" view
callable used when the context is of the type ``MyModel``.
-#. *Lines 5-6*. We define a :term:`view callable` named ``my_view``, which
+#. *Lines 6-7*. We define a :term:`view callable` named ``my_view``, which
we decorated in the step above. This view callable is a *function* we
write generated by the ``zodb`` scaffold that is given a
``request`` and which returns a dictionary. The ``mytemplate.pt``
@@ -165,10 +162,10 @@ Configuration in ``development.ini``
The ``development.ini`` (in the tutorial :term:`project` directory, as
opposed to the tutorial :term:`package` directory) looks like this:
-.. literalinclude:: src/views/development.ini
+.. literalinclude:: src/basiclayout/development.ini
:language: ini
-Note the existence of an ``[app:main]`` section which specifies our WSGI
+Note the existence of a ``[app:main]`` section which specifies our WSGI
application. Our ZODB database settings are specified as the
``zodbconn.uri`` setting within this section. This value, and the other
values within this section are passed as ``**settings`` to the ``main``
diff --git a/docs/tutorials/wiki/definingmodels.rst b/docs/tutorials/wiki/definingmodels.rst
index 1a5d38b10..49372179f 100644
--- a/docs/tutorials/wiki/definingmodels.rst
+++ b/docs/tutorials/wiki/definingmodels.rst
@@ -14,9 +14,6 @@ constructors". Both our Page and Wiki constructors will be class objects. A
single instance of the "Wiki" class will serve as a container for "Page"
objects, which will be instances of the "Page" class.
-The source code for this tutorial stage can be browsed via
-`http://github.com/Pylons/pyramid/tree/1.3-branch/docs/tutorials/wiki/src/models/
-<http://github.com/Pylons/pyramid/tree/1.3-branch/docs/tutorials/wiki/src/models/>`_.
Delete the Database
-------------------
@@ -36,7 +33,7 @@ Edit ``models.py``
.. note::
There is nothing automagically special about the filename ``models.py``. A
- project may have many models throughout its codebase in arbitrarily-named
+ project may have many models throughout its codebase in arbitrarily named
files. Files implementing models often have ``model`` in their filenames,
or they may live in a Python subpackage of your application package named
``models``, but this is only by convention.
@@ -59,11 +56,11 @@ of the root model is also always ``None``.
Then we'll add a ``Page`` class. This class should inherit from the
:class:`persistent.Persistent` class. We'll also give it an ``__init__``
method that accepts a single parameter named ``data``. This parameter will
-contain the :term:`ReStructuredText` body representing the wiki page content.
+contain the :term:`reStructuredText` body representing the wiki page content.
Note that ``Page`` objects don't have an initial ``__name__`` or
``__parent__`` attribute. All objects in a traversal graph must have a
``__name__`` and a ``__parent__`` attribute. We don't specify these here
-because both ``__name__`` and ``__parent__`` will be set by by a :term:`view`
+because both ``__name__`` and ``__parent__`` will be set by a :term:`view`
function when a Page is added to our Wiki mapping.
As a last step, we want to change the ``appmaker`` function in our
diff --git a/docs/tutorials/wiki/definingviews.rst b/docs/tutorials/wiki/definingviews.rst
index 529603546..efcc7bf21 100644
--- a/docs/tutorials/wiki/definingviews.rst
+++ b/docs/tutorials/wiki/definingviews.rst
@@ -28,9 +28,6 @@ assumed to return a :term:`response` object.
We're going to define several :term:`view callable` functions, then wire them
into :app:`Pyramid` using some :term:`view configuration`.
-The source code for this tutorial stage can be browsed via
-`http://github.com/Pylons/pyramid/tree/1.3-branch/docs/tutorials/wiki/src/views/
-<http://github.com/Pylons/pyramid/tree/1.3-branch/docs/tutorials/wiki/src/views/>`_.
Declaring Dependencies in Our ``setup.py`` File
===============================================
@@ -115,7 +112,7 @@ The curried function named ``check`` is used as the first argument to
each WikiWord match found in the content. If the wiki (our page's
``__parent__``) already contains a page with the matched WikiWord name, the
``check`` function generates a view link to be used as the substitution value
-and returns it. If the wiki does not already contain a page with with the
+and returns it. If the wiki does not already contain a page with the
matched WikiWord name, the function generates an "add" link as the
substitution value and returns it.
diff --git a/docs/tutorials/wiki/design.rst b/docs/tutorials/wiki/design.rst
index c94612fb1..eb785dd1c 100644
--- a/docs/tutorials/wiki/design.rst
+++ b/docs/tutorials/wiki/design.rst
@@ -4,7 +4,7 @@ Design
Following is a quick overview of our wiki application, to help
us understand the changes that we will be doing next in our
-default files generated by the ``zodb`` scafffold.
+default files generated by the ``zodb`` scaffold.
Overall
-------
@@ -37,8 +37,8 @@ Views
-----
There will be three views to handle the normal operations of adding,
-editing and viewing wiki pages, plus one view for the wiki front page.
-Two templates will be used, one for viewing, and one for both for adding
+editing, and viewing wiki pages, plus one view for the wiki front page.
+Two templates will be used, one for viewing, and one for both adding
and editing wiki pages.
The default templating systems in :app:`Pyramid` are
@@ -53,11 +53,11 @@ Security
We'll eventually be adding security to our application. The components we'll
use to do this are below.
-- USERS, a dictionary mapping users names to their
+- USERS, a dictionary mapping usernames to their
corresponding passwords.
-- GROUPS, a dictionary mapping user names to a
- list of groups they belong to.
+- GROUPS, a dictionary mapping usernames to a
+ list of groups to which they belong to.
- ``groupfinder``, an *authorization callback* that looks up
USERS and GROUPS. It will be provided in a new
diff --git a/docs/tutorials/wiki/index.rst b/docs/tutorials/wiki/index.rst
index c918f8765..981d135c7 100644
--- a/docs/tutorials/wiki/index.rst
+++ b/docs/tutorials/wiki/index.rst
@@ -10,8 +10,9 @@ tutorial, the developer will have created a basic Wiki application with
authentication.
For cut and paste purposes, the source code for all stages of this
-tutorial can be browsed at `https://github.com/Pylons/pyramid/tree/1.3-branch/docs/tutorials/wiki/src
-<https://github.com/Pylons/pyramid/tree/1.3-branch/docs/tutorials/wiki/src>`_.
+tutorial can be browsed on GitHub at `docs/tutorials/wiki/src
+<https://github.com/Pylons/pyramid/tree/master/docs/tutorials/wiki/src>`_,
+which corresponds to the same location if you have Pyramid sources.
.. toctree::
:maxdepth: 2
diff --git a/docs/tutorials/wiki/installation.rst b/docs/tutorials/wiki/installation.rst
index 868c99dee..b545cdba0 100644
--- a/docs/tutorials/wiki/installation.rst
+++ b/docs/tutorials/wiki/installation.rst
@@ -2,52 +2,15 @@
Installation
============
-For the most part, the installation process for this tutorial
-duplicates the steps described in :ref:`installing_chapter` and
-:ref:`project_narr`, however it also explains how to install
-additional libraries for tutorial purposes.
-
Preparation
-========================
+===========
-Please take the following steps to prepare for the tutorial. The
-steps to prepare for the tutorial are slightly different depending on
-whether you're using UNIX or Windows.
+Follow the steps in :ref:`installing_chapter`, but name the virtualenv
+directory ``pyramidtut``.
Preparation, UNIX
-----------------
-#. If you don't already have a Python 2.6 interpreter installed on
- your system, obtain, install, or find `Python 2.6
- <http://python.org/download/releases/2.6.6/>`_ for your system.
-
-#. Make sure the Python development headers are installed on your system. If
- you've installed Python from source, these will already be installed. If
- you're using a system Python, you may have to install a ``python-dev``
- package (e.g. ``apt-get python-dev``). The headers are not required for
- Pyramid itself, just for dependencies of the tutorial.
-
-#. Install the latest `setuptools` into the Python you
- obtained/installed/found in the step above: download `ez_setup.py
- <http://peak.telecommunity.com/dist/ez_setup.py>`_ and run it using
- the ``python`` interpreter of your Python 2.6 installation:
-
- .. code-block:: text
-
- $ /path/to/my/Python-2.6/bin/python ez_setup.py
-
-#. Use that Python's `bin/easy_install` to install `virtualenv`:
-
- .. code-block:: text
-
- $ /path/to/my/Python-2.6/bin/easy_install virtualenv
-
-#. Use that Python's virtualenv to make a workspace:
-
- .. code-block:: text
-
- $ path/to/my/Python-2.6/bin/virtualenv --no-site-packages \
- pyramidtut
#. Switch to the ``pyramidtut`` directory:
@@ -55,18 +18,7 @@ Preparation, UNIX
$ cd pyramidtut
-#. (Optional) Consider using ``source bin/activate`` to make your
- shell environment wired to use the virtualenv.
-
-#. Use ``easy_install`` to get :app:`Pyramid` and its direct
- dependencies installed:
-
- .. code-block:: text
-
- $ bin/easy_install pyramid
-
-#. Use ``easy_install`` to install ``docutils``, ``pyramid_tm``,
- ``pyramid_zodbconn``, ``pyramid_debugtoolbar``, ``nose`` and ``coverage``:
+#. Install tutorial dependencies:
.. code-block:: text
@@ -76,30 +28,6 @@ Preparation, UNIX
Preparation, Windows
--------------------
-#. Install, or find `Python 2.6
- <http://python.org/download/releases/2.6.6/>`_ for your system.
-
-#. Install the latest `setuptools` into the Python you
- obtained/installed/found in the step above: download `ez_setup.py
- <http://peak.telecommunity.com/dist/ez_setup.py>`_ and run it using
- the ``python`` interpreter of your Python 2.6 installation using a
- command prompt:
-
- .. code-block:: text
-
- c:\> c:\Python26\python ez_setup.py
-
-#. Use that Python's `bin/easy_install` to install `virtualenv`:
-
- .. code-block:: text
-
- c:\> c:\Python26\Scripts\easy_install virtualenv
-
-#. Use that Python's virtualenv to make a workspace:
-
- .. code-block:: text
-
- c:\> c:\Python26\Scripts\virtualenv --no-site-packages pyramidtut
#. Switch to the ``pyramidtut`` directory:
@@ -107,18 +35,7 @@ Preparation, Windows
c:\> cd pyramidtut
-#. (Optional) Consider using ``bin\activate.bat`` to make your shell
- environment wired to use the virtualenv.
-
-#. Use ``easy_install`` to get :app:`Pyramid` and its direct
- dependencies installed:
-
- .. code-block:: text
-
- c:\pyramidtut> Scripts\easy_install pyramid
-
-#. Use ``easy_install`` to install ``docutils``, ``pyramid_tm``,
- ``pyramid_zodbconn``, ``pyramid_debugtoolbar``, ``nose`` and ``coverage``:
+#. Install tutorial dependencies:
.. code-block:: text
@@ -276,8 +193,7 @@ assumptions:
.. note::
- :app:`Pyramid` supports any persistent storage mechanism (e.g. a SQL
- database or filesystem files, etc). :app:`Pyramid` also supports an
- additional mechanism to map URLs to code (:term:`URL dispatch`). However,
- for the purposes of this tutorial, we'll only be using traversal and ZODB.
-
+ :app:`Pyramid` supports any persistent storage mechanism (e.g., a SQL
+ database or filesystem files). :app:`Pyramid` also supports an additional
+ mechanism to map URLs to code (:term:`URL dispatch`). However, for the
+ purposes of this tutorial, we'll only be using traversal and ZODB.
diff --git a/docs/tutorials/wiki/src/authorization/development.ini b/docs/tutorials/wiki/src/authorization/development.ini
index 996caa741..72bd22e54 100644
--- a/docs/tutorials/wiki/src/authorization/development.ini
+++ b/docs/tutorials/wiki/src/authorization/development.ini
@@ -1,5 +1,11 @@
+###
+# app configuration
+# http://docs.pylonsproject.org/projects/pyramid/en/latest/narr/environment.html
+###
+
[app:main]
use = egg:tutorial
+
pyramid.reload_templates = true
pyramid.debug_authorization = false
pyramid.debug_notfound = false
@@ -13,15 +19,26 @@ pyramid.includes =
tm.attempts = 3
zodbconn.uri = file://%(here)s/Data.fs?connection_cache_size=20000
+# 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 = 0.0.0.0
port = 6543
-# Begin logging configuration
+###
+# logging configuration
+# http://docs.pylonsproject.org/projects/pyramid/en/latest/narr/logging.html
+###
[loggers]
-keys = root
+keys = root, tutorial
[handlers]
keys = console
@@ -33,6 +50,11 @@ keys = generic
level = INFO
handlers = console
+[logger_tutorial]
+level = DEBUG
+handlers =
+qualname = tutorial
+
[handler_console]
class = StreamHandler
args = (sys.stderr,)
@@ -41,5 +63,3 @@ formatter = generic
[formatter_generic]
format = %(asctime)s %(levelname)-5.5s [%(name)s][%(threadName)s] %(message)s
-
-# End logging configuration
diff --git a/docs/tutorials/wiki/src/authorization/production.ini b/docs/tutorials/wiki/src/authorization/production.ini
index ca8107802..d9bf27c42 100644
--- a/docs/tutorials/wiki/src/authorization/production.ini
+++ b/docs/tutorials/wiki/src/authorization/production.ini
@@ -1,5 +1,11 @@
+###
+# app configuration
+# http://docs.pylonsproject.org/projects/pyramid/en/latest/narr/environment.html
+###
+
[app:main]
use = egg:tutorial
+
pyramid.reload_templates = false
pyramid.debug_authorization = false
pyramid.debug_notfound = false
@@ -12,12 +18,19 @@ pyramid.includes =
tm.attempts = 3
zodbconn.uri = file://%(here)s/Data.fs?connection_cache_size=20000
+###
+# wsgi server configuration
+###
+
[server:main]
use = egg:waitress#main
host = 0.0.0.0
port = 6543
-# Begin logging configuration
+###
+# logging configuration
+# http://docs.pylonsproject.org/projects/pyramid/en/latest/narr/logging.html
+###
[loggers]
keys = root, tutorial
@@ -45,5 +58,3 @@ formatter = generic
[formatter_generic]
format = %(asctime)s %(levelname)-5.5s [%(name)s][%(threadName)s] %(message)s
-
-# End logging configuration
diff --git a/docs/tutorials/wiki/src/authorization/setup.py b/docs/tutorials/wiki/src/authorization/setup.py
index 31c51dbcf..3164fd724 100644
--- a/docs/tutorials/wiki/src/authorization/setup.py
+++ b/docs/tutorials/wiki/src/authorization/setup.py
@@ -9,6 +9,7 @@ CHANGES = open(os.path.join(here, 'CHANGES.txt')).read()
requires = [
'pyramid',
'pyramid_zodbconn',
+ 'transaction',
'pyramid_tm',
'pyramid_debugtoolbar',
'ZODB3',
@@ -19,11 +20,10 @@ requires = [
setup(name='tutorial',
version='0.0',
description='tutorial',
- long_description=README + '\n\n' + CHANGES,
+ long_description=README + '\n\n' + CHANGES,
classifiers=[
- "Intended Audience :: Developers",
- "Framework :: Pylons",
"Programming Language :: Python",
+ "Framework :: Pyramid",
"Topic :: Internet :: WWW/HTTP",
"Topic :: Internet :: WWW/HTTP :: WSGI :: Application",
],
@@ -37,9 +37,8 @@ setup(name='tutorial',
install_requires=requires,
tests_require=requires,
test_suite="tutorial",
- entry_points = """\
+ entry_points="""\
[paste.app_factory]
main = tutorial:main
""",
)
-
diff --git a/docs/tutorials/wiki/src/authorization/tutorial/__init__.py b/docs/tutorials/wiki/src/authorization/tutorial/__init__.py
index b42e01d03..8ea8f8fa3 100644
--- a/docs/tutorials/wiki/src/authorization/tutorial/__init__.py
+++ b/docs/tutorials/wiki/src/authorization/tutorial/__init__.py
@@ -11,8 +11,9 @@ def root_factory(request):
conn = get_connection(request)
return appmaker(conn.root())
+
def main(global_config, **settings):
- """ This function returns a WSGI application.
+ """ This function returns a Pyramid WSGI application.
"""
authn_policy = AuthTktAuthenticationPolicy(
'sosecret', callback=groupfinder, hashalg='sha512')
diff --git a/docs/tutorials/wiki/src/authorization/tutorial/templates/mytemplate.pt b/docs/tutorials/wiki/src/authorization/tutorial/templates/mytemplate.pt
index 3597c679b..84824f605 100644
--- a/docs/tutorials/wiki/src/authorization/tutorial/templates/mytemplate.pt
+++ b/docs/tutorials/wiki/src/authorization/tutorial/templates/mytemplate.pt
@@ -6,9 +6,9 @@
<meta name="keywords" content="python web application" />
<meta name="description" content="pyramid web application" />
<link rel="shortcut icon" href="/static/favicon.ico" />
+ <link rel="stylesheet" href="/static/pylons.css" type="text/css" media="screen" charset="utf-8" />
<link rel="stylesheet" href="http://static.pylonsproject.org/fonts/nobile/stylesheet.css" media="screen" />
<link rel="stylesheet" href="http://static.pylonsproject.org/fonts/neuton/stylesheet.css" media="screen" />
- <link rel="stylesheet" href="/static/pylons.css" type="text/css" media="screen" charset="utf-8" />
<!--[if lte IE 6]>
<link rel="stylesheet" href="/static/ie6.css" type="text/css" media="screen" charset="utf-8" />
<![endif]-->
@@ -41,7 +41,7 @@
<h2>Pyramid links</h2>
<ul class="links">
<li>
- <a href="http://pylonsproject.org">Pylons Website</a>
+ <a href="http://pylonsproject.org/">Pylons Website</a>
</li>
<li>
<a href="http://docs.pylonsproject.org/projects/pyramid/current/#narrative-documentation">Narrative Documentation</a>
@@ -70,7 +70,7 @@
</div>
</div>
<div id="footer">
- <div class="footer">&copy; Copyright 2008-2011, Agendaless Consulting.</div>
+ <div class="footer">&copy; Copyright 2008-2012, Agendaless Consulting.</div>
</div>
</body>
</html>
diff --git a/docs/tutorials/wiki/src/authorization/tutorial/tests.py b/docs/tutorials/wiki/src/authorization/tutorial/tests.py
index 77e7cce29..0b9046d47 100644
--- a/docs/tutorials/wiki/src/authorization/tutorial/tests.py
+++ b/docs/tutorials/wiki/src/authorization/tutorial/tests.py
@@ -30,6 +30,7 @@ class WikiModelTests(unittest.TestCase):
self.assertEqual(wiki.__name__, None)
class AppmakerTests(unittest.TestCase):
+
def _callFUT(self, zodb_root):
from .models import appmaker
return appmaker(zodb_root)
@@ -63,7 +64,7 @@ class ViewPageTests(unittest.TestCase):
info = self._callFUT(context, request)
self.assertEqual(info['page'], context)
self.assertEqual(
- info['content'],
+ info['content'],
'<div class="document">\n'
'<p>Hello <a href="http://example.com/add_page/CruelWorld">'
'CruelWorld</a> '
@@ -85,9 +86,9 @@ class AddPageTests(unittest.TestCase):
request.subpath = ['AnotherPage']
info = self._callFUT(context, request)
self.assertEqual(info['page'].data,'')
- self.assertEqual(info['save_url'],
- request.resource_url(
- context, 'add_page', 'AnotherPage'))
+ self.assertEqual(
+ info['save_url'],
+ request.resource_url(context, 'add_page', 'AnotherPage'))
def test_it_submitted(self):
context = testing.DummyResource()
diff --git a/docs/tutorials/wiki/src/authorization/tutorial/views.py b/docs/tutorials/wiki/src/authorization/tutorial/views.py
index 50485d279..77956b1e3 100644
--- a/docs/tutorials/wiki/src/authorization/tutorial/views.py
+++ b/docs/tutorials/wiki/src/authorization/tutorial/views.py
@@ -64,8 +64,8 @@ def add_page(context, request):
page.__name__ = pagename
page.__parent__ = context
- return dict(page = page, save_url = save_url,
- logged_in = authenticated_userid(request))
+ return dict(page=page, save_url=save_url,
+ logged_in=authenticated_userid(request))
@view_config(name='edit_page', context='.models.Page',
renderer='templates/edit.pt',
@@ -75,9 +75,9 @@ def edit_page(context, request):
context.data = request.params['body']
return HTTPFound(location = request.resource_url(context))
- return dict(page = context,
- save_url = request.resource_url(context, 'edit_page'),
- logged_in = authenticated_userid(request))
+ return dict(page=context,
+ save_url=request.resource_url(context, 'edit_page'),
+ logged_in=authenticated_userid(request))
@view_config(context='.models.Wiki', name='login',
renderer='templates/login.pt')
diff --git a/docs/tutorials/wiki/src/basiclayout/development.ini b/docs/tutorials/wiki/src/basiclayout/development.ini
index f637ebaa6..72bd22e54 100644
--- a/docs/tutorials/wiki/src/basiclayout/development.ini
+++ b/docs/tutorials/wiki/src/basiclayout/development.ini
@@ -1,5 +1,11 @@
+###
+# app configuration
+# http://docs.pylonsproject.org/projects/pyramid/en/latest/narr/environment.html
+###
+
[app:main]
use = egg:tutorial
+
pyramid.reload_templates = true
pyramid.debug_authorization = false
pyramid.debug_notfound = false
@@ -13,15 +19,26 @@ pyramid.includes =
tm.attempts = 3
zodbconn.uri = file://%(here)s/Data.fs?connection_cache_size=20000
+# 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 = 0.0.0.0
port = 6543
-# Begin logging configuration
+###
+# logging configuration
+# http://docs.pylonsproject.org/projects/pyramid/en/latest/narr/logging.html
+###
[loggers]
-keys = root
+keys = root, tutorial
[handlers]
keys = console
@@ -33,6 +50,11 @@ keys = generic
level = INFO
handlers = console
+[logger_tutorial]
+level = DEBUG
+handlers =
+qualname = tutorial
+
[handler_console]
class = StreamHandler
args = (sys.stderr,)
@@ -40,6 +62,4 @@ level = NOTSET
formatter = generic
[formatter_generic]
-format = %(asctime)s %(levelname)-5.5s [%(name)s] %(message)s
-
-# End logging configuration
+format = %(asctime)s %(levelname)-5.5s [%(name)s][%(threadName)s] %(message)s
diff --git a/docs/tutorials/wiki/src/basiclayout/production.ini b/docs/tutorials/wiki/src/basiclayout/production.ini
index ca8107802..d9bf27c42 100644
--- a/docs/tutorials/wiki/src/basiclayout/production.ini
+++ b/docs/tutorials/wiki/src/basiclayout/production.ini
@@ -1,5 +1,11 @@
+###
+# app configuration
+# http://docs.pylonsproject.org/projects/pyramid/en/latest/narr/environment.html
+###
+
[app:main]
use = egg:tutorial
+
pyramid.reload_templates = false
pyramid.debug_authorization = false
pyramid.debug_notfound = false
@@ -12,12 +18,19 @@ pyramid.includes =
tm.attempts = 3
zodbconn.uri = file://%(here)s/Data.fs?connection_cache_size=20000
+###
+# wsgi server configuration
+###
+
[server:main]
use = egg:waitress#main
host = 0.0.0.0
port = 6543
-# Begin logging configuration
+###
+# logging configuration
+# http://docs.pylonsproject.org/projects/pyramid/en/latest/narr/logging.html
+###
[loggers]
keys = root, tutorial
@@ -45,5 +58,3 @@ formatter = generic
[formatter_generic]
format = %(asctime)s %(levelname)-5.5s [%(name)s][%(threadName)s] %(message)s
-
-# End logging configuration
diff --git a/docs/tutorials/wiki/src/basiclayout/setup.py b/docs/tutorials/wiki/src/basiclayout/setup.py
index 43600e239..4998be902 100644
--- a/docs/tutorials/wiki/src/basiclayout/setup.py
+++ b/docs/tutorials/wiki/src/basiclayout/setup.py
@@ -9,6 +9,7 @@ CHANGES = open(os.path.join(here, 'CHANGES.txt')).read()
requires = [
'pyramid',
'pyramid_zodbconn',
+ 'transaction',
'pyramid_tm',
'pyramid_debugtoolbar',
'ZODB3',
@@ -18,10 +19,10 @@ requires = [
setup(name='tutorial',
version='0.0',
description='tutorial',
- long_description=README + '\n\n' + CHANGES,
+ long_description=README + '\n\n' + CHANGES,
classifiers=[
"Programming Language :: Python",
- "Framework :: Pylons",
+ "Framework :: Pyramid",
"Topic :: Internet :: WWW/HTTP",
"Topic :: Internet :: WWW/HTTP :: WSGI :: Application",
],
@@ -32,12 +33,11 @@ setup(name='tutorial',
packages=find_packages(),
include_package_data=True,
zip_safe=False,
- install_requires = requires,
- tests_require= requires,
+ install_requires=requires,
+ tests_require=requires,
test_suite="tutorial",
- entry_points = """\
+ entry_points="""\
[paste.app_factory]
main = tutorial:main
""",
)
-
diff --git a/docs/tutorials/wiki/src/basiclayout/tutorial/__init__.py b/docs/tutorials/wiki/src/basiclayout/tutorial/__init__.py
index b63933fc5..c3bb87a62 100644
--- a/docs/tutorials/wiki/src/basiclayout/tutorial/__init__.py
+++ b/docs/tutorials/wiki/src/basiclayout/tutorial/__init__.py
@@ -2,10 +2,12 @@ from pyramid.config import Configurator
from pyramid_zodbconn import get_connection
from .models import appmaker
+
def root_factory(request):
conn = get_connection(request)
return appmaker(conn.root())
+
def main(global_config, **settings):
""" This function returns a Pyramid WSGI application.
"""
diff --git a/docs/tutorials/wiki/src/basiclayout/tutorial/models.py b/docs/tutorials/wiki/src/basiclayout/tutorial/models.py
index 8dd0f5a49..a94b36ef4 100644
--- a/docs/tutorials/wiki/src/basiclayout/tutorial/models.py
+++ b/docs/tutorials/wiki/src/basiclayout/tutorial/models.py
@@ -1,8 +1,10 @@
from persistent.mapping import PersistentMapping
+
class MyModel(PersistentMapping):
__parent__ = __name__ = None
+
def appmaker(zodb_root):
if not 'app_root' in zodb_root:
app_root = MyModel()
diff --git a/docs/tutorials/wiki/src/basiclayout/tutorial/templates/mytemplate.pt b/docs/tutorials/wiki/src/basiclayout/tutorial/templates/mytemplate.pt
index 557e071ed..84824f605 100644
--- a/docs/tutorials/wiki/src/basiclayout/tutorial/templates/mytemplate.pt
+++ b/docs/tutorials/wiki/src/basiclayout/tutorial/templates/mytemplate.pt
@@ -6,9 +6,9 @@
<meta name="keywords" content="python web application" />
<meta name="description" content="pyramid web application" />
<link rel="shortcut icon" href="/static/favicon.ico" />
+ <link rel="stylesheet" href="/static/pylons.css" type="text/css" media="screen" charset="utf-8" />
<link rel="stylesheet" href="http://static.pylonsproject.org/fonts/nobile/stylesheet.css" media="screen" />
<link rel="stylesheet" href="http://static.pylonsproject.org/fonts/neuton/stylesheet.css" media="screen" />
- <link rel="stylesheet" href="/static/pylons.css" type="text/css" media="screen" charset="utf-8" />
<!--[if lte IE 6]>
<link rel="stylesheet" href="/static/ie6.css" type="text/css" media="screen" charset="utf-8" />
<![endif]-->
@@ -70,7 +70,7 @@
</div>
</div>
<div id="footer">
- <div class="footer">&copy; Copyright 2008-2011, Agendaless Consulting.</div>
+ <div class="footer">&copy; Copyright 2008-2012, Agendaless Consulting.</div>
</div>
</body>
</html>
diff --git a/docs/tutorials/wiki/src/basiclayout/tutorial/tests.py b/docs/tutorials/wiki/src/basiclayout/tutorial/tests.py
index 8d2374be1..7f6523c66 100644
--- a/docs/tutorials/wiki/src/basiclayout/tutorial/tests.py
+++ b/docs/tutorials/wiki/src/basiclayout/tutorial/tests.py
@@ -14,4 +14,3 @@ class ViewTests(unittest.TestCase):
request = testing.DummyRequest()
info = my_view(request)
self.assertEqual(info['project'], 'tutorial')
-
diff --git a/docs/tutorials/wiki/src/basiclayout/tutorial/views.py b/docs/tutorials/wiki/src/basiclayout/tutorial/views.py
index 4265b6bf7..628ce15ed 100644
--- a/docs/tutorials/wiki/src/basiclayout/tutorial/views.py
+++ b/docs/tutorials/wiki/src/basiclayout/tutorial/views.py
@@ -1,6 +1,7 @@
from pyramid.view import view_config
from .models import MyModel
+
@view_config(context=MyModel, renderer='templates/mytemplate.pt')
def my_view(request):
- return {'project':'tutorial'}
+ return {'project': 'tutorial'}
diff --git a/docs/tutorials/wiki/src/models/development.ini b/docs/tutorials/wiki/src/models/development.ini
index 996caa741..72bd22e54 100644
--- a/docs/tutorials/wiki/src/models/development.ini
+++ b/docs/tutorials/wiki/src/models/development.ini
@@ -1,5 +1,11 @@
+###
+# app configuration
+# http://docs.pylonsproject.org/projects/pyramid/en/latest/narr/environment.html
+###
+
[app:main]
use = egg:tutorial
+
pyramid.reload_templates = true
pyramid.debug_authorization = false
pyramid.debug_notfound = false
@@ -13,15 +19,26 @@ pyramid.includes =
tm.attempts = 3
zodbconn.uri = file://%(here)s/Data.fs?connection_cache_size=20000
+# 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 = 0.0.0.0
port = 6543
-# Begin logging configuration
+###
+# logging configuration
+# http://docs.pylonsproject.org/projects/pyramid/en/latest/narr/logging.html
+###
[loggers]
-keys = root
+keys = root, tutorial
[handlers]
keys = console
@@ -33,6 +50,11 @@ keys = generic
level = INFO
handlers = console
+[logger_tutorial]
+level = DEBUG
+handlers =
+qualname = tutorial
+
[handler_console]
class = StreamHandler
args = (sys.stderr,)
@@ -41,5 +63,3 @@ formatter = generic
[formatter_generic]
format = %(asctime)s %(levelname)-5.5s [%(name)s][%(threadName)s] %(message)s
-
-# End logging configuration
diff --git a/docs/tutorials/wiki/src/models/production.ini b/docs/tutorials/wiki/src/models/production.ini
index ca8107802..d9bf27c42 100644
--- a/docs/tutorials/wiki/src/models/production.ini
+++ b/docs/tutorials/wiki/src/models/production.ini
@@ -1,5 +1,11 @@
+###
+# app configuration
+# http://docs.pylonsproject.org/projects/pyramid/en/latest/narr/environment.html
+###
+
[app:main]
use = egg:tutorial
+
pyramid.reload_templates = false
pyramid.debug_authorization = false
pyramid.debug_notfound = false
@@ -12,12 +18,19 @@ pyramid.includes =
tm.attempts = 3
zodbconn.uri = file://%(here)s/Data.fs?connection_cache_size=20000
+###
+# wsgi server configuration
+###
+
[server:main]
use = egg:waitress#main
host = 0.0.0.0
port = 6543
-# Begin logging configuration
+###
+# logging configuration
+# http://docs.pylonsproject.org/projects/pyramid/en/latest/narr/logging.html
+###
[loggers]
keys = root, tutorial
@@ -45,5 +58,3 @@ formatter = generic
[formatter_generic]
format = %(asctime)s %(levelname)-5.5s [%(name)s][%(threadName)s] %(message)s
-
-# End logging configuration
diff --git a/docs/tutorials/wiki/src/models/setup.py b/docs/tutorials/wiki/src/models/setup.py
index 43600e239..4998be902 100644
--- a/docs/tutorials/wiki/src/models/setup.py
+++ b/docs/tutorials/wiki/src/models/setup.py
@@ -9,6 +9,7 @@ CHANGES = open(os.path.join(here, 'CHANGES.txt')).read()
requires = [
'pyramid',
'pyramid_zodbconn',
+ 'transaction',
'pyramid_tm',
'pyramid_debugtoolbar',
'ZODB3',
@@ -18,10 +19,10 @@ requires = [
setup(name='tutorial',
version='0.0',
description='tutorial',
- long_description=README + '\n\n' + CHANGES,
+ long_description=README + '\n\n' + CHANGES,
classifiers=[
"Programming Language :: Python",
- "Framework :: Pylons",
+ "Framework :: Pyramid",
"Topic :: Internet :: WWW/HTTP",
"Topic :: Internet :: WWW/HTTP :: WSGI :: Application",
],
@@ -32,12 +33,11 @@ setup(name='tutorial',
packages=find_packages(),
include_package_data=True,
zip_safe=False,
- install_requires = requires,
- tests_require= requires,
+ install_requires=requires,
+ tests_require=requires,
test_suite="tutorial",
- entry_points = """\
+ entry_points="""\
[paste.app_factory]
main = tutorial:main
""",
)
-
diff --git a/docs/tutorials/wiki/src/models/tutorial/__init__.py b/docs/tutorials/wiki/src/models/tutorial/__init__.py
index c59f36e7b..c3bb87a62 100644
--- a/docs/tutorials/wiki/src/models/tutorial/__init__.py
+++ b/docs/tutorials/wiki/src/models/tutorial/__init__.py
@@ -2,15 +2,16 @@ from pyramid.config import Configurator
from pyramid_zodbconn import get_connection
from .models import appmaker
+
def root_factory(request):
conn = get_connection(request)
return appmaker(conn.root())
+
def main(global_config, **settings):
- """ This function returns a WSGI application.
+ """ This function returns a Pyramid WSGI application.
"""
config = Configurator(root_factory=root_factory, settings=settings)
config.add_static_view('static', 'static', cache_max_age=3600)
config.scan()
return config.make_wsgi_app()
-
diff --git a/docs/tutorials/wiki/src/models/tutorial/templates/mytemplate.pt b/docs/tutorials/wiki/src/models/tutorial/templates/mytemplate.pt
index 3597c679b..84824f605 100644
--- a/docs/tutorials/wiki/src/models/tutorial/templates/mytemplate.pt
+++ b/docs/tutorials/wiki/src/models/tutorial/templates/mytemplate.pt
@@ -6,9 +6,9 @@
<meta name="keywords" content="python web application" />
<meta name="description" content="pyramid web application" />
<link rel="shortcut icon" href="/static/favicon.ico" />
+ <link rel="stylesheet" href="/static/pylons.css" type="text/css" media="screen" charset="utf-8" />
<link rel="stylesheet" href="http://static.pylonsproject.org/fonts/nobile/stylesheet.css" media="screen" />
<link rel="stylesheet" href="http://static.pylonsproject.org/fonts/neuton/stylesheet.css" media="screen" />
- <link rel="stylesheet" href="/static/pylons.css" type="text/css" media="screen" charset="utf-8" />
<!--[if lte IE 6]>
<link rel="stylesheet" href="/static/ie6.css" type="text/css" media="screen" charset="utf-8" />
<![endif]-->
@@ -41,7 +41,7 @@
<h2>Pyramid links</h2>
<ul class="links">
<li>
- <a href="http://pylonsproject.org">Pylons Website</a>
+ <a href="http://pylonsproject.org/">Pylons Website</a>
</li>
<li>
<a href="http://docs.pylonsproject.org/projects/pyramid/current/#narrative-documentation">Narrative Documentation</a>
@@ -70,7 +70,7 @@
</div>
</div>
<div id="footer">
- <div class="footer">&copy; Copyright 2008-2011, Agendaless Consulting.</div>
+ <div class="footer">&copy; Copyright 2008-2012, Agendaless Consulting.</div>
</div>
</body>
</html>
diff --git a/docs/tutorials/wiki/src/models/tutorial/views.py b/docs/tutorials/wiki/src/models/tutorial/views.py
index 7c1f1d228..628ce15ed 100644
--- a/docs/tutorials/wiki/src/models/tutorial/views.py
+++ b/docs/tutorials/wiki/src/models/tutorial/views.py
@@ -1,5 +1,7 @@
from pyramid.view import view_config
+from .models import MyModel
-@view_config(renderer='templates/mytemplate.pt')
+
+@view_config(context=MyModel, renderer='templates/mytemplate.pt')
def my_view(request):
- return {'project':'tutorial'}
+ return {'project': 'tutorial'}
diff --git a/docs/tutorials/wiki/src/tests/development.ini b/docs/tutorials/wiki/src/tests/development.ini
index 996caa741..72bd22e54 100644
--- a/docs/tutorials/wiki/src/tests/development.ini
+++ b/docs/tutorials/wiki/src/tests/development.ini
@@ -1,5 +1,11 @@
+###
+# app configuration
+# http://docs.pylonsproject.org/projects/pyramid/en/latest/narr/environment.html
+###
+
[app:main]
use = egg:tutorial
+
pyramid.reload_templates = true
pyramid.debug_authorization = false
pyramid.debug_notfound = false
@@ -13,15 +19,26 @@ pyramid.includes =
tm.attempts = 3
zodbconn.uri = file://%(here)s/Data.fs?connection_cache_size=20000
+# 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 = 0.0.0.0
port = 6543
-# Begin logging configuration
+###
+# logging configuration
+# http://docs.pylonsproject.org/projects/pyramid/en/latest/narr/logging.html
+###
[loggers]
-keys = root
+keys = root, tutorial
[handlers]
keys = console
@@ -33,6 +50,11 @@ keys = generic
level = INFO
handlers = console
+[logger_tutorial]
+level = DEBUG
+handlers =
+qualname = tutorial
+
[handler_console]
class = StreamHandler
args = (sys.stderr,)
@@ -41,5 +63,3 @@ formatter = generic
[formatter_generic]
format = %(asctime)s %(levelname)-5.5s [%(name)s][%(threadName)s] %(message)s
-
-# End logging configuration
diff --git a/docs/tutorials/wiki/src/tests/production.ini b/docs/tutorials/wiki/src/tests/production.ini
index ca8107802..d9bf27c42 100644
--- a/docs/tutorials/wiki/src/tests/production.ini
+++ b/docs/tutorials/wiki/src/tests/production.ini
@@ -1,5 +1,11 @@
+###
+# app configuration
+# http://docs.pylonsproject.org/projects/pyramid/en/latest/narr/environment.html
+###
+
[app:main]
use = egg:tutorial
+
pyramid.reload_templates = false
pyramid.debug_authorization = false
pyramid.debug_notfound = false
@@ -12,12 +18,19 @@ pyramid.includes =
tm.attempts = 3
zodbconn.uri = file://%(here)s/Data.fs?connection_cache_size=20000
+###
+# wsgi server configuration
+###
+
[server:main]
use = egg:waitress#main
host = 0.0.0.0
port = 6543
-# Begin logging configuration
+###
+# logging configuration
+# http://docs.pylonsproject.org/projects/pyramid/en/latest/narr/logging.html
+###
[loggers]
keys = root, tutorial
@@ -45,5 +58,3 @@ formatter = generic
[formatter_generic]
format = %(asctime)s %(levelname)-5.5s [%(name)s][%(threadName)s] %(message)s
-
-# End logging configuration
diff --git a/docs/tutorials/wiki/src/tests/setup.py b/docs/tutorials/wiki/src/tests/setup.py
index a7ad7317c..702d34c4c 100644
--- a/docs/tutorials/wiki/src/tests/setup.py
+++ b/docs/tutorials/wiki/src/tests/setup.py
@@ -9,6 +9,7 @@ CHANGES = open(os.path.join(here, 'CHANGES.txt')).read()
requires = [
'pyramid',
'pyramid_zodbconn',
+ 'transaction',
'pyramid_tm',
'pyramid_debugtoolbar',
'ZODB3',
@@ -20,11 +21,10 @@ requires = [
setup(name='tutorial',
version='0.0',
description='tutorial',
- long_description=README + '\n\n' + CHANGES,
+ long_description=README + '\n\n' + CHANGES,
classifiers=[
- "Intended Audience :: Developers",
- "Framework :: Pylons",
"Programming Language :: Python",
+ "Framework :: Pyramid",
"Topic :: Internet :: WWW/HTTP",
"Topic :: Internet :: WWW/HTTP :: WSGI :: Application",
],
@@ -38,9 +38,8 @@ setup(name='tutorial',
install_requires=requires,
tests_require=requires,
test_suite="tutorial",
- entry_points = """\
+ entry_points="""\
[paste.app_factory]
main = tutorial:main
""",
)
-
diff --git a/docs/tutorials/wiki/src/tests/tutorial/__init__.py b/docs/tutorials/wiki/src/tests/tutorial/__init__.py
index b42e01d03..8ea8f8fa3 100644
--- a/docs/tutorials/wiki/src/tests/tutorial/__init__.py
+++ b/docs/tutorials/wiki/src/tests/tutorial/__init__.py
@@ -11,8 +11,9 @@ def root_factory(request):
conn = get_connection(request)
return appmaker(conn.root())
+
def main(global_config, **settings):
- """ This function returns a WSGI application.
+ """ This function returns a Pyramid WSGI application.
"""
authn_policy = AuthTktAuthenticationPolicy(
'sosecret', callback=groupfinder, hashalg='sha512')
diff --git a/docs/tutorials/wiki/src/tests/tutorial/templates/mytemplate.pt b/docs/tutorials/wiki/src/tests/tutorial/templates/mytemplate.pt
index 3597c679b..84824f605 100644
--- a/docs/tutorials/wiki/src/tests/tutorial/templates/mytemplate.pt
+++ b/docs/tutorials/wiki/src/tests/tutorial/templates/mytemplate.pt
@@ -6,9 +6,9 @@
<meta name="keywords" content="python web application" />
<meta name="description" content="pyramid web application" />
<link rel="shortcut icon" href="/static/favicon.ico" />
+ <link rel="stylesheet" href="/static/pylons.css" type="text/css" media="screen" charset="utf-8" />
<link rel="stylesheet" href="http://static.pylonsproject.org/fonts/nobile/stylesheet.css" media="screen" />
<link rel="stylesheet" href="http://static.pylonsproject.org/fonts/neuton/stylesheet.css" media="screen" />
- <link rel="stylesheet" href="/static/pylons.css" type="text/css" media="screen" charset="utf-8" />
<!--[if lte IE 6]>
<link rel="stylesheet" href="/static/ie6.css" type="text/css" media="screen" charset="utf-8" />
<![endif]-->
@@ -41,7 +41,7 @@
<h2>Pyramid links</h2>
<ul class="links">
<li>
- <a href="http://pylonsproject.org">Pylons Website</a>
+ <a href="http://pylonsproject.org/">Pylons Website</a>
</li>
<li>
<a href="http://docs.pylonsproject.org/projects/pyramid/current/#narrative-documentation">Narrative Documentation</a>
@@ -70,7 +70,7 @@
</div>
</div>
<div id="footer">
- <div class="footer">&copy; Copyright 2008-2011, Agendaless Consulting.</div>
+ <div class="footer">&copy; Copyright 2008-2012, Agendaless Consulting.</div>
</div>
</body>
</html>
diff --git a/docs/tutorials/wiki/src/tests/tutorial/tests.py b/docs/tutorials/wiki/src/tests/tutorial/tests.py
index 81f7a1882..c435a4519 100644
--- a/docs/tutorials/wiki/src/tests/tutorial/tests.py
+++ b/docs/tutorials/wiki/src/tests/tutorial/tests.py
@@ -30,6 +30,7 @@ class WikiModelTests(unittest.TestCase):
self.assertEqual(wiki.__name__, None)
class AppmakerTests(unittest.TestCase):
+
def _callFUT(self, zodb_root):
from .models import appmaker
return appmaker(zodb_root)
@@ -142,7 +143,7 @@ class FunctionalTests(unittest.TestCase):
'pyramid.includes': ['pyramid_zodbconn', 'pyramid_tm'] }
app = main({}, **settings)
- self.db = app.registry.zodb_database
+ self.db = app.registry._zodb_databases['']
from webtest import TestApp
self.testapp = TestApp(app)
diff --git a/docs/tutorials/wiki/src/tests/tutorial/views.py b/docs/tutorials/wiki/src/tests/tutorial/views.py
index 50485d279..77956b1e3 100644
--- a/docs/tutorials/wiki/src/tests/tutorial/views.py
+++ b/docs/tutorials/wiki/src/tests/tutorial/views.py
@@ -64,8 +64,8 @@ def add_page(context, request):
page.__name__ = pagename
page.__parent__ = context
- return dict(page = page, save_url = save_url,
- logged_in = authenticated_userid(request))
+ return dict(page=page, save_url=save_url,
+ logged_in=authenticated_userid(request))
@view_config(name='edit_page', context='.models.Page',
renderer='templates/edit.pt',
@@ -75,9 +75,9 @@ def edit_page(context, request):
context.data = request.params['body']
return HTTPFound(location = request.resource_url(context))
- return dict(page = context,
- save_url = request.resource_url(context, 'edit_page'),
- logged_in = authenticated_userid(request))
+ return dict(page=context,
+ save_url=request.resource_url(context, 'edit_page'),
+ logged_in=authenticated_userid(request))
@view_config(context='.models.Wiki', name='login',
renderer='templates/login.pt')
diff --git a/docs/tutorials/wiki/src/views/development.ini b/docs/tutorials/wiki/src/views/development.ini
index f637ebaa6..72bd22e54 100644
--- a/docs/tutorials/wiki/src/views/development.ini
+++ b/docs/tutorials/wiki/src/views/development.ini
@@ -1,5 +1,11 @@
+###
+# app configuration
+# http://docs.pylonsproject.org/projects/pyramid/en/latest/narr/environment.html
+###
+
[app:main]
use = egg:tutorial
+
pyramid.reload_templates = true
pyramid.debug_authorization = false
pyramid.debug_notfound = false
@@ -13,15 +19,26 @@ pyramid.includes =
tm.attempts = 3
zodbconn.uri = file://%(here)s/Data.fs?connection_cache_size=20000
+# 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 = 0.0.0.0
port = 6543
-# Begin logging configuration
+###
+# logging configuration
+# http://docs.pylonsproject.org/projects/pyramid/en/latest/narr/logging.html
+###
[loggers]
-keys = root
+keys = root, tutorial
[handlers]
keys = console
@@ -33,6 +50,11 @@ keys = generic
level = INFO
handlers = console
+[logger_tutorial]
+level = DEBUG
+handlers =
+qualname = tutorial
+
[handler_console]
class = StreamHandler
args = (sys.stderr,)
@@ -40,6 +62,4 @@ level = NOTSET
formatter = generic
[formatter_generic]
-format = %(asctime)s %(levelname)-5.5s [%(name)s] %(message)s
-
-# End logging configuration
+format = %(asctime)s %(levelname)-5.5s [%(name)s][%(threadName)s] %(message)s
diff --git a/docs/tutorials/wiki/src/views/production.ini b/docs/tutorials/wiki/src/views/production.ini
index ca8107802..d9bf27c42 100644
--- a/docs/tutorials/wiki/src/views/production.ini
+++ b/docs/tutorials/wiki/src/views/production.ini
@@ -1,5 +1,11 @@
+###
+# app configuration
+# http://docs.pylonsproject.org/projects/pyramid/en/latest/narr/environment.html
+###
+
[app:main]
use = egg:tutorial
+
pyramid.reload_templates = false
pyramid.debug_authorization = false
pyramid.debug_notfound = false
@@ -12,12 +18,19 @@ pyramid.includes =
tm.attempts = 3
zodbconn.uri = file://%(here)s/Data.fs?connection_cache_size=20000
+###
+# wsgi server configuration
+###
+
[server:main]
use = egg:waitress#main
host = 0.0.0.0
port = 6543
-# Begin logging configuration
+###
+# logging configuration
+# http://docs.pylonsproject.org/projects/pyramid/en/latest/narr/logging.html
+###
[loggers]
keys = root, tutorial
@@ -45,5 +58,3 @@ formatter = generic
[formatter_generic]
format = %(asctime)s %(levelname)-5.5s [%(name)s][%(threadName)s] %(message)s
-
-# End logging configuration
diff --git a/docs/tutorials/wiki/src/views/setup.py b/docs/tutorials/wiki/src/views/setup.py
index a6be89b2e..3164fd724 100644
--- a/docs/tutorials/wiki/src/views/setup.py
+++ b/docs/tutorials/wiki/src/views/setup.py
@@ -9,6 +9,7 @@ CHANGES = open(os.path.join(here, 'CHANGES.txt')).read()
requires = [
'pyramid',
'pyramid_zodbconn',
+ 'transaction',
'pyramid_tm',
'pyramid_debugtoolbar',
'ZODB3',
@@ -19,11 +20,10 @@ requires = [
setup(name='tutorial',
version='0.0',
description='tutorial',
- long_description=README + '\n\n' + CHANGES,
+ long_description=README + '\n\n' + CHANGES,
classifiers=[
- "Intended Audience :: Developers",
- "Framework :: Pylons",
"Programming Language :: Python",
+ "Framework :: Pyramid",
"Topic :: Internet :: WWW/HTTP",
"Topic :: Internet :: WWW/HTTP :: WSGI :: Application",
],
@@ -37,7 +37,7 @@ setup(name='tutorial',
install_requires=requires,
tests_require=requires,
test_suite="tutorial",
- entry_points = """\
+ entry_points="""\
[paste.app_factory]
main = tutorial:main
""",
diff --git a/docs/tutorials/wiki/src/views/tutorial/__init__.py b/docs/tutorials/wiki/src/views/tutorial/__init__.py
index 957a0b705..c3bb87a62 100644
--- a/docs/tutorials/wiki/src/views/tutorial/__init__.py
+++ b/docs/tutorials/wiki/src/views/tutorial/__init__.py
@@ -1,15 +1,17 @@
from pyramid.config import Configurator
from pyramid_zodbconn import get_connection
-from tutorial.models import appmaker
+from .models import appmaker
+
def root_factory(request):
conn = get_connection(request)
return appmaker(conn.root())
+
def main(global_config, **settings):
- """ This function returns a WSGI application.
+ """ This function returns a Pyramid WSGI application.
"""
config = Configurator(root_factory=root_factory, settings=settings)
config.add_static_view('static', 'static', cache_max_age=3600)
- config.scan('tutorial')
+ config.scan()
return config.make_wsgi_app()
diff --git a/docs/tutorials/wiki/src/views/tutorial/templates/mytemplate.pt b/docs/tutorials/wiki/src/views/tutorial/templates/mytemplate.pt
index 3597c679b..84824f605 100644
--- a/docs/tutorials/wiki/src/views/tutorial/templates/mytemplate.pt
+++ b/docs/tutorials/wiki/src/views/tutorial/templates/mytemplate.pt
@@ -6,9 +6,9 @@
<meta name="keywords" content="python web application" />
<meta name="description" content="pyramid web application" />
<link rel="shortcut icon" href="/static/favicon.ico" />
+ <link rel="stylesheet" href="/static/pylons.css" type="text/css" media="screen" charset="utf-8" />
<link rel="stylesheet" href="http://static.pylonsproject.org/fonts/nobile/stylesheet.css" media="screen" />
<link rel="stylesheet" href="http://static.pylonsproject.org/fonts/neuton/stylesheet.css" media="screen" />
- <link rel="stylesheet" href="/static/pylons.css" type="text/css" media="screen" charset="utf-8" />
<!--[if lte IE 6]>
<link rel="stylesheet" href="/static/ie6.css" type="text/css" media="screen" charset="utf-8" />
<![endif]-->
@@ -41,7 +41,7 @@
<h2>Pyramid links</h2>
<ul class="links">
<li>
- <a href="http://pylonsproject.org">Pylons Website</a>
+ <a href="http://pylonsproject.org/">Pylons Website</a>
</li>
<li>
<a href="http://docs.pylonsproject.org/projects/pyramid/current/#narrative-documentation">Narrative Documentation</a>
@@ -70,7 +70,7 @@
</div>
</div>
<div id="footer">
- <div class="footer">&copy; Copyright 2008-2011, Agendaless Consulting.</div>
+ <div class="footer">&copy; Copyright 2008-2012, Agendaless Consulting.</div>
</div>
</body>
</html>
diff --git a/docs/tutorials/wiki/src/views/tutorial/tests.py b/docs/tutorials/wiki/src/views/tutorial/tests.py
index 9eac2a432..663c9f405 100644
--- a/docs/tutorials/wiki/src/views/tutorial/tests.py
+++ b/docs/tutorials/wiki/src/views/tutorial/tests.py
@@ -5,7 +5,7 @@ from pyramid import testing
class PageModelTests(unittest.TestCase):
def _getTargetClass(self):
- from tutorial.models import Page
+ from .models import Page
return Page
def _makeOne(self, data=u'some data'):
@@ -14,11 +14,11 @@ class PageModelTests(unittest.TestCase):
def test_constructor(self):
instance = self._makeOne()
self.assertEqual(instance.data, u'some data')
-
+
class WikiModelTests(unittest.TestCase):
def _getTargetClass(self):
- from tutorial.models import Wiki
+ from .models import Wiki
return Wiki
def _makeOne(self):
@@ -30,8 +30,9 @@ class WikiModelTests(unittest.TestCase):
self.assertEqual(wiki.__name__, None)
class AppmakerTests(unittest.TestCase):
+
def _callFUT(self, zodb_root):
- from tutorial.models import appmaker
+ from .models import appmaker
return appmaker(zodb_root)
def test_it(self):
@@ -42,7 +43,7 @@ class AppmakerTests(unittest.TestCase):
class ViewWikiTests(unittest.TestCase):
def test_it(self):
- from tutorial.views import view_wiki
+ from .views import view_wiki
context = testing.DummyResource()
request = testing.DummyRequest()
response = view_wiki(context, request)
@@ -50,7 +51,7 @@ class ViewWikiTests(unittest.TestCase):
class ViewPageTests(unittest.TestCase):
def _callFUT(self, context, request):
- from tutorial.views import view_page
+ from .views import view_page
return view_page(context, request)
def test_it(self):
@@ -63,7 +64,7 @@ class ViewPageTests(unittest.TestCase):
info = self._callFUT(context, request)
self.assertEqual(info['page'], context)
self.assertEqual(
- info['content'],
+ info['content'],
'<div class="document">\n'
'<p>Hello <a href="http://example.com/add_page/CruelWorld">'
'CruelWorld</a> '
@@ -72,11 +73,11 @@ class ViewPageTests(unittest.TestCase):
'</p>\n</div>\n')
self.assertEqual(info['edit_url'],
'http://example.com/thepage/edit_page')
-
-
+
+
class AddPageTests(unittest.TestCase):
def _callFUT(self, context, request):
- from tutorial.views import add_page
+ from .views import add_page
return add_page(context, request)
def test_it_notsubmitted(self):
@@ -88,7 +89,7 @@ class AddPageTests(unittest.TestCase):
self.assertEqual(
info['save_url'],
request.resource_url(context, 'add_page', 'AnotherPage'))
-
+
def test_it_submitted(self):
context = testing.DummyResource()
request = testing.DummyRequest({'form.submitted':True,
@@ -102,7 +103,7 @@ class AddPageTests(unittest.TestCase):
class EditPageTests(unittest.TestCase):
def _callFUT(self, context, request):
- from tutorial.views import edit_page
+ from .views import edit_page
return edit_page(context, request)
def test_it_notsubmitted(self):
@@ -112,7 +113,7 @@ class EditPageTests(unittest.TestCase):
self.assertEqual(info['page'], context)
self.assertEqual(info['save_url'],
request.resource_url(context, 'edit_page'))
-
+
def test_it_submitted(self):
context = testing.DummyResource()
request = testing.DummyRequest({'form.submitted':True,
diff --git a/docs/tutorials/wiki/src/views/tutorial/views.py b/docs/tutorials/wiki/src/views/tutorial/views.py
index b0c15297f..61517c31d 100644
--- a/docs/tutorials/wiki/src/views/tutorial/views.py
+++ b/docs/tutorials/wiki/src/views/tutorial/views.py
@@ -56,5 +56,5 @@ def edit_page(context, request):
context.data = request.params['body']
return HTTPFound(location = request.resource_url(context))
- return dict(page = context,
- save_url = request.resource_url(context, 'edit_page'))
+ return dict(page=context,
+ save_url=request.resource_url(context, 'edit_page'))
diff --git a/docs/tutorials/wiki/tests.rst b/docs/tutorials/wiki/tests.rst
index ebb4d93dc..49bc780e8 100644
--- a/docs/tutorials/wiki/tests.rst
+++ b/docs/tutorials/wiki/tests.rst
@@ -6,9 +6,6 @@ We will now add tests for the models and the views and a few functional
tests in the ``tests.py``. Tests ensure that an application works, and
that it continues to work after some changes are made in the future.
-The source code for this tutorial stage can be browsed via
-`http://github.com/Pylons/pyramid/tree/1.3-branch/docs/tutorials/wiki/src/tests/
-<http://github.com/Pylons/pyramid/tree/1.3-branch/docs/tutorials/wiki/src/tests/>`_.
Test the Models
===============
@@ -17,8 +14,8 @@ We write tests for the model classes and the appmaker. Changing
``tests.py``, we'll write a separate test class for each model class, and
we'll write a test class for the ``appmaker``.
-To do so, we'll retain the ``tutorial.tests.ViewTests`` class provided as a
-result of the ``zodb`` project generator. We'll add three test
+To do so, we'll retain the ``tutorial.tests.ViewTests`` class that was
+generated as part of the ``zodb`` scaffold. We'll add three test
classes: one for the ``Page`` model named ``PageModelTests``, one for the
``Wiki`` model named ``WikiModelTests``, and one for the appmaker named
``AppmakerTests``.
@@ -51,8 +48,8 @@ below:
:linenos:
:language: python
-Run the Tests
-=============
+Running the Tests
+=================
We can run these tests by using ``setup.py test`` in the same way we did in
:ref:`running_tests`. However, first we must edit our ``setup.py`` to
@@ -62,7 +59,8 @@ Change the ``requires`` list in ``setup.py`` to include ``WebTest``.
.. literalinclude:: src/tests/setup.py
:linenos:
:language: python
- :lines: 9-18
+ :lines: 9-19
+ :emphasize-lines: 10
After we've added a dependency on WebTest in ``setup.py``, we need to rerun
``setup.py develop`` to get WebTest installed into our virtualenv. Assuming
diff --git a/docs/tutorials/wiki2/authorization.rst b/docs/tutorials/wiki2/authorization.rst
index 1ddf8c82d..5ede26920 100644
--- a/docs/tutorials/wiki2/authorization.rst
+++ b/docs/tutorials/wiki2/authorization.rst
@@ -14,7 +14,7 @@ anyone with access to the server to view pages.
We will also add a login page and a logout link on all the
pages. The login page will be shown when a user is denied
-access to any of the views that require a permission, instead of
+access to any of the views that require permission, instead of
a default "403 Forbidden" page.
We will implement the access control with the following steps:
@@ -36,9 +36,6 @@ Then we will add the login and logout feature:
* Add a "Logout" link to be shown when logged in and viewing or editing a page
(``view.pt``, ``edit.pt``).
-The source code for this tutorial stage can be browsed at
-`http://github.com/Pylons/pyramid/tree/1.3-branch/docs/tutorials/wiki2/src/authorization/
-<http://github.com/Pylons/pyramid/tree/1.3-branch/docs/tutorials/wiki2/src/authorization/>`_.
Access Control
--------------
@@ -62,7 +59,7 @@ returns one of these values:
- If the userid *does not* exist in the system, it will
return ``None``.
-For example, ``groupfinder('editor', request )`` returns ['group:editor'],
+For example, ``groupfinder('editor', request )`` returns ``['group:editor']``,
``groupfinder('viewer', request)`` returns [], and ``groupfinder('admin', request)``
returns ``None``. We will use ``groupfinder()`` as an :term:`authentication policy`
"callback" that will provide the :term:`principal` or principals
@@ -86,7 +83,7 @@ statement at the head:
Add the following class definition:
.. literalinclude:: src/authorization/tutorial/models.py
- :lines: 35-39
+ :lines: 36-40
:linenos:
:language: python
@@ -112,7 +109,7 @@ parameter to our :term:`Configurator` constructor, that points to
the class we created above:
.. literalinclude:: src/authorization/tutorial/__init__.py
- :lines: 23-24
+ :lines: 24-25
:linenos:
:emphasize-lines: 2
:language: python
@@ -144,19 +141,19 @@ add these import statements:
Now add those policies to the configuration:
.. literalinclude:: src/authorization/tutorial/__init__.py
- :lines: 20-26
+ :lines: 21-27
:linenos:
:emphasize-lines: 1-3,6-7
:language: python
(Only the highlighted lines need to be added.)
-We are enabling an ``AuthTktAuthenticationPolicy``, it is based in an
-auth ticket that may be included in the request, and an
-``ACLAuthorizationPolicy`` that uses an ACL to determine the allow or deny
-outcome for a view.
+We are enabling an ``AuthTktAuthenticationPolicy``, which is based in an
+auth ticket that may be included in the request.
+We are also enabling an ``ACLAuthorizationPolicy``, which uses an ACL to
+determine the *allow* or *deny* outcome for a view.
-Note that the :class:`pyramid.authentication.AuthTktAuthenticationPolicy`
+Note that the :class:`~pyramid.authentication.AuthTktAuthenticationPolicy`
constructor accepts two arguments: ``secret`` and ``callback``. ``secret`` is
a string representing an encryption key used by the "authentication ticket"
machinery represented by this policy: it is required. The ``callback`` is the
@@ -206,7 +203,7 @@ Go back to ``tutorial/tutorial/__init__.py`` and add these two
routes:
.. literalinclude:: src/authorization/tutorial/__init__.py
- :lines: 29-30
+ :lines: 30-31
:linenos:
:language: python
@@ -303,9 +300,8 @@ like this:
(Only the highlighted line needs to be added.)
-:meth:`~pyramid.security.authenticated_userid()` will return None
-if the user is not authenticated, or some user id it the user
-is authenticated.
+The :meth:`~pyramid.security.authenticated_userid` method will return None
+if the user is not authenticated.
Add a "Logout" link when logged in
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -333,7 +329,7 @@ when we're done:
.. literalinclude:: src/authorization/tutorial/__init__.py
:linenos:
- :emphasize-lines: 2-3,7,23-24,20-26,29-30
+ :emphasize-lines: 2-3,7,21-23,25-27,30-31
:language: python
(Only the highlighted lines need to be added.)
@@ -343,7 +339,7 @@ when we're done:
.. literalinclude:: src/authorization/tutorial/models.py
:linenos:
- :emphasize-lines: 1-4,35-39
+ :emphasize-lines: 1-4,36-40
:language: python
(Only the highlighted lines need to be added.)
diff --git a/docs/tutorials/wiki2/background.rst b/docs/tutorials/wiki2/background.rst
index 9933adc27..1f9582903 100644
--- a/docs/tutorials/wiki2/background.rst
+++ b/docs/tutorials/wiki2/background.rst
@@ -11,9 +11,8 @@ To code along with this tutorial, the developer will need a UNIX
machine with development tools (Mac OS X with XCode, any Linux or BSD
variant, etc) *or* a Windows system of any kind.
-.. warning::
+.. note::
- This tutorial has been written for Python 2. It is unlikely to work
- without modification under Python 3.
+ This tutorial runs on both Python 2 and 3 without modification.
Have fun!
diff --git a/docs/tutorials/wiki2/basiclayout.rst b/docs/tutorials/wiki2/basiclayout.rst
index dbd130c36..68be4ee7c 100644
--- a/docs/tutorials/wiki2/basiclayout.rst
+++ b/docs/tutorials/wiki2/basiclayout.rst
@@ -6,9 +6,6 @@ The starter files generated by the ``alchemy`` scaffold are very basic, but
they provide a good orientation for the high-level patterns common to most
:term:`url dispatch` -based :app:`Pyramid` projects.
-The source code for this tutorial stage can be browsed at
-`http://github.com/Pylons/pyramid/tree/1.3-branch/docs/tutorials/wiki2/src/basiclayout/
-<http://github.com/Pylons/pyramid/tree/1.3-branch/docs/tutorials/wiki2/src/basiclayout/>`_.
Application Configuration with ``__init__.py``
----------------------------------------------
@@ -45,24 +42,23 @@ When you invoke the ``pserve development.ini`` command, the ``main`` function
above is executed. It accepts some settings and returns a :term:`WSGI`
application. (See :ref:`startup_chapter` for more about ``pserve``.)
-The main function first creates a SQLAlchemy database engine using
+The main function first creates a :term:`SQLAlchemy` database engine using
``engine_from_config`` from the ``sqlalchemy.`` prefixed settings in the
``development.ini`` file's ``[app:main]`` section. This will be a URI
(something like ``sqlite://``):
.. literalinclude:: src/basiclayout/tutorial/__init__.py
- :lines: 12
- :linenos:
+ :lines: 13
:language: py
``main`` then initializes our SQLAlchemy session object, passing it the
engine:
.. literalinclude:: src/basiclayout/tutorial/__init__.py
- :lines: 13
+ :lines: 14
:language: py
-``main`` subsequently initializes our SQLAlchemy declarative Base object,
+``main`` subsequently initializes our SQLAlchemy declarative ``Base`` object,
assigning the engine we created to the ``bind`` attribute of it's
``metadata`` object. This allows table definitions done imperatively
(instead of declaratively, via a class statement) to work. We won't use any
@@ -71,13 +67,13 @@ forgotten about this tutorial, you won't be left scratching your head when it
doesn't work.
.. literalinclude:: src/basiclayout/tutorial/__init__.py
- :lines: 14
+ :lines: 15
:language: py
The next step of ``main`` is to construct a :term:`Configurator` object:
.. literalinclude:: src/basiclayout/tutorial/__init__.py
- :lines: 15
+ :lines: 16
:language: py
``settings`` is passed to the Configurator as a keyword argument with the
@@ -90,15 +86,15 @@ deployment-related values such as ``pyramid.reload_templates``,
two arguments: ``static`` (the name), and ``static`` (the path):
.. literalinclude:: src/basiclayout/tutorial/__init__.py
- :lines: 16
+ :lines: 17
:language: py
This registers a static resource view which will match any URL that starts
-with the prefix ``/static`` (by virtue of the first argument to add_static
-view). This will serve up static resources for us from within the ``static``
-directory of our ``tutorial`` package, in this case, via
+with the prefix ``/static`` (by virtue of the first argument to
+``add_static_view``). This will serve up static resources for us from within
+the ``static`` directory of our ``tutorial`` package, in this case, via
``http://localhost:6543/static/`` and below (by virtue of the second argument
-to add_static_view). With this declaration, we're saying that any URL that
+to ``add_static_view``). With this declaration, we're saying that any URL that
starts with ``/static`` should go to the static view; any remainder of its
path (e.g. the ``/foo`` in ``/static/foo``) will be used to compose a path to
a static file resource, such as a CSS file.
@@ -108,20 +104,21 @@ via the :meth:`pyramid.config.Configurator.add_route` method that will be
used when the URL is ``/``:
.. literalinclude:: src/basiclayout/tutorial/__init__.py
- :lines: 17
+ :lines: 18
:language: py
Since this route has a ``pattern`` equalling ``/`` it is the route that will
be matched when the URL ``/`` is visited, e.g. ``http://localhost:6543/``.
-``main`` next calls the ``scan`` method of the configurator, which will
-recursively scan our ``tutorial`` package, looking for ``@view_config`` (and
+``main`` next calls the ``scan`` method of the configurator
+(:meth:`pyramid.config.Configurator.scan`), which will recursively scan our
+``tutorial`` package, looking for ``@view_config`` (and
other special) decorators. When it finds a ``@view_config`` decorator, a
view configuration will be registered, which will allow one of our
application URLs to be mapped to some code.
.. literalinclude:: src/basiclayout/tutorial/__init__.py
- :lines: 18
+ :lines: 19
:language: py
Finally, ``main`` is finished configuring things, so it uses the
@@ -129,7 +126,7 @@ Finally, ``main`` is finished configuring things, so it uses the
:term:`WSGI` application:
.. literalinclude:: src/basiclayout/tutorial/__init__.py
- :lines: 19
+ :lines: 20
:language: py
View Declarations via ``views.py``
@@ -171,6 +168,12 @@ application. Without being processed by ``scan``, the decorator effectively
does nothing. ``@view_config`` is inert without being detected via a
:term:`scan`.
+The sample ``my_view()`` created by the scaffold uses a ``try:`` and ``except:``
+clause, to detect if there is a problem accessing the project database and
+provide an alternate error response. That response will include the text
+shown at the end of the file, which will be displayed in the browser to
+inform the user about possible actions to take to solve the problem.
+
Content Models with ``models.py``
---------------------------------
@@ -191,11 +194,10 @@ Let's examine this in detail. First, we need some imports to support later code:
:linenos:
:language: py
-Next we set up a SQLAlchemy "DBSession" object:
+Next we set up a SQLAlchemy ``DBSession`` object:
.. literalinclude:: src/basiclayout/tutorial/models.py
:lines: 16
- :linenos:
:language: py
``scoped_session`` and ``sessionmaker`` are standard SQLAlchemy helpers.
@@ -224,8 +226,9 @@ To give a simple example of a model class, we define one named ``MyModel``:
:linenos:
:language: py
-Our example model has an ``__init__`` that takes a two arguments (``name``,
-and ``value``). It stores these values as ``self.name`` and ``self.value``
+Our example model has an ``__init__`` method that takes a two arguments
+(``name``, and ``value``). It stores these values as ``self.name`` and
+``self.value``
within the ``__init__`` function itself. The ``MyModel`` class also has a
``__tablename__`` attribute. This informs SQLAlchemy which table to use to
store the data representing instances of this class.
diff --git a/docs/tutorials/wiki2/definingmodels.rst b/docs/tutorials/wiki2/definingmodels.rst
index 1653faf4a..bd1cb00d7 100644
--- a/docs/tutorials/wiki2/definingmodels.rst
+++ b/docs/tutorials/wiki2/definingmodels.rst
@@ -2,20 +2,17 @@
Defining the Domain Model
=========================
-The first change we'll make to our stock pcreate-generated application will
+The first change we'll make to our stock ``pcreate``-generated application will
be to define a :term:`domain model` constructor representing a wiki page.
We'll do this inside our ``models.py`` file.
-The source code for this tutorial stage can be browsed at
-`http://github.com/Pylons/pyramid/tree/1.3-branch/docs/tutorials/wiki2/src/models/
-<http://github.com/Pylons/pyramid/tree/1.3-branch/docs/tutorials/wiki2/src/models/>`_.
Making Edits to ``models.py``
-----------------------------
.. note::
- There is nothing automagically special about the filename ``models.py``. A
+ There is nothing special about the filename ``models.py``. A
project may have many models throughout its codebase in arbitrarily-named
files. Files implementing models often have ``model`` in their filenames
(or they may live in a Python subpackage of your application package named
@@ -27,11 +24,11 @@ following:
.. literalinclude:: src/models/tutorial/models.py
:linenos:
:language: py
- :emphasize-lines: 19-21,24,26,28
+ :emphasize-lines: 20-22,25,27,29
(The highlighted lines are the ones that need to be changed.)
-The first thing we've done is to do is remove the stock ``MyModel`` class
+The first thing we've done is remove the stock ``MyModel`` class
from the generated ``models.py`` file. The ``MyModel`` class is only a
sample and we're not going to use it.
@@ -46,8 +43,8 @@ this class inherits from an instance of
As you can see, our ``Page`` class has a class level attribute
``__tablename__`` which equals the string ``'pages'``. This means that
-SQLAlchemy will store our wiki data in a SQL table named ``pages``. Our Page
-class will also have class-level attributes named ``id``, ``name`` and
+SQLAlchemy will store our wiki data in a SQL table named ``pages``. Our
+``Page`` class will also have class-level attributes named ``id``, ``name`` and
``data`` (all instances of :class:`sqlalchemy.Column`). These will map to
columns in the ``pages`` table. The ``id`` attribute will be the primary key
in the table. The ``name`` attribute will be a text attribute, each value of
@@ -73,29 +70,19 @@ following:
.. literalinclude:: src/models/tutorial/scripts/initializedb.py
:linenos:
:language: python
- :emphasize-lines: 14,34
+ :emphasize-lines: 14,36
(Only the highlighted lines need to be changed.)
-Reinitializing the Database
----------------------------
+Installing the Project and re-initializing the Database
+-------------------------------------------------------
+
+Redo the steps in :ref:`installing_project_in_dev_mode`.
Because our model has changed, in order to reinitialize the database, we need
to rerun the ``initialize_tutorial_db`` command to pick up the changes you've made
-to both the models.py file and to the initializedb.py file. From the root of the
-``tutorial`` project, directory execute the following commands.
-
-On UNIX:
-
-.. code-block:: text
-
- $ ../bin/initialize_tutorial_db development.ini
-
-On Windows:
-
-.. code-block:: text
-
- c:\pyramidtut\tutorial> ..\Scripts\initialize_tutorial_db development.ini
+to both the models.py file and to the initializedb.py file.
+See :ref:`initialize_db_wiki2` for instructions.
Success will look something like this::
diff --git a/docs/tutorials/wiki2/definingviews.rst b/docs/tutorials/wiki2/definingviews.rst
index a54996e3c..e83a88198 100644
--- a/docs/tutorials/wiki2/definingviews.rst
+++ b/docs/tutorials/wiki2/definingviews.rst
@@ -16,9 +16,6 @@ instance, if a call to :meth:`pyramid.config.Configurator.add_route` in
have a ``'one'`` key with the value ``'foo'`` and a ``'two'`` key with the
value ``'bar'``.
-The source code for this tutorial stage can be browsed at
-`http://github.com/Pylons/pyramid/tree/1.3-branch/docs/tutorials/wiki2/src/views/
-<http://github.com/Pylons/pyramid/tree/1.3-branch/docs/tutorials/wiki2/src/views/>`_.
Declaring Dependencies in Our ``setup.py`` File
===============================================
@@ -26,7 +23,7 @@ Declaring Dependencies in Our ``setup.py`` File
The view code in our application will depend on a package which is not a
dependency of the original "tutorial" application. The original "tutorial"
application was generated by the ``pcreate`` command; it doesn't know
-about our custom application requirements.
+about our custom application requirements.
We need to add a dependency on the ``docutils`` package to our ``tutorial``
package's ``setup.py`` file by assigning this dependency to the ``requires`` parameter in ``setup()``.
@@ -123,14 +120,14 @@ the :class:`pyramid.interfaces.IResponse` interface like
It uses the :meth:`pyramid.request.Request.route_url` API to construct a
URL to the ``FrontPage`` page (e.g. ``http://localhost:6543/FrontPage``), which
-is used as the "location" of the HTTPFound response, forming an HTTP redirect.
+is used as the "location" of the ``HTTPFound`` response, forming an HTTP redirect.
The ``view_page`` view function
-------------------------------
``view_page()`` is used to display a single page of our
wiki. It renders the :term:`ReStructuredText` body of a page (stored as
-the ``data`` attribute of a Page object) as HTML. Then it substitutes an
+the ``data`` attribute of a ``Page`` model object) as HTML. Then it substitutes an
HTML anchor for each *WikiWord* reference in the rendered HTML using a
compiled regular expression.
@@ -139,12 +136,12 @@ compiled regular expression.
:linenos:
:language: python
-The curried ``check()`` function is used as the first argument to
+The ``check()`` function is used as the first argument to
``wikiwords.sub``, indicating that it should be called to provide a value for
each WikiWord match found in the content. If the wiki already contains a
page with the matched WikiWord name, ``check()`` generates a view
link to be used as the substitution value and returns it. If the wiki does
-not already contain a page with with the matched WikiWord name, ``check()``
+not already contain a page with the matched WikiWord name, ``check()``
generates an "add" link as the substitution value and returns it.
As a result, the ``content`` variable is now a fully formed bit of HTML
@@ -181,6 +178,13 @@ the page we'd like to add. If our add view is invoked via,
e.g. ``http://localhost:6543/add_page/SomeName``, the value for
``'pagename'`` in the ``matchdict`` will be ``'SomeName'``.
+If the view execution *is* a result of a form submission (i.e. the expression
+``'form.submitted' in request.params`` is ``True``), we scrape the page body
+from the form data, create a Page object with this page body and the name
+taken from ``matchdict['pagename']``, and save it into the database using
+``DBSession.add``. We then redirect back to the ``view_page`` view for the
+newly created page.
+
If the view execution is *not* a result of a form submission (i.e. the
expression ``'form.submitted' in request.params`` is ``False``), the view
callable renders a template. To do so, it generates a "save url" which the
@@ -191,13 +195,6 @@ in order to satisfy the edit form's desire to have *some* page object
exposed as ``page``. :app:`Pyramid` will render the template associated
with this view to a response.
-If the view execution *is* a result of a form submission (i.e. the expression
-``'form.submitted' in request.params`` is ``True``), we scrape the page body
-from the form data, create a Page object with this page body and the name
-taken from ``matchdict['pagename']``, and save it into the database using
-``DBSession.add``. We then redirect back to the ``view_page`` view for the
-newly created page.
-
The ``edit_page`` view function
-------------------------------
@@ -212,17 +209,17 @@ matching the name of the page the user wants to edit.
:linenos:
:language: python
-If the view execution is *not* a result of a form submission (i.e. the
-expression ``'form.submitted' in request.params`` is ``False``), the view
-simply renders the edit form, passing the page object and a ``save_url``
-which will be used as the action of the generated form.
-
If the view execution *is* a result of a form submission (i.e. the expression
``'form.submitted' in request.params`` is ``True``), the view grabs the
``body`` element of the request parameters and sets it as the ``data``
attribute of the page object. It then redirects to the ``view_page`` view
of the wiki page.
+If the view execution is *not* a result of a form submission (i.e. the
+expression ``'form.submitted' in request.params`` is ``False``), the view
+simply renders the edit form, passing the page object and a ``save_url``
+which will be used as the action of the generated form.
+
Adding Templates
================
@@ -342,7 +339,7 @@ something like:
.. literalinclude:: src/views/tutorial/__init__.py
:linenos:
:language: python
- :emphasize-lines: 17-20
+ :emphasize-lines: 18-21
(The highlighted lines are the ones that need to be added or edited.)
@@ -358,7 +355,7 @@ each of the following URLs, check that the result is as expected:
of the FrontPage page object.
- ``http://localhost:6543/FrontPage`` in a browser invokes
- the ``view_page`` view of the front page page object.
+ the ``view_page`` view of the front page object.
- ``http://localhost:6543/FrontPage/edit_page`` in a browser
invokes the edit view for the front page object.
@@ -366,7 +363,7 @@ each of the following URLs, check that the result is as expected:
- ``http://localhost:6543/add_page/SomePageName`` in a
browser invokes the add view for a page.
-- To generate an error, visit ``http://localhost:6543/add_page`` which
+- To generate an error, visit ``http://localhost:6543/foobars/edit_page`` which
will generate a ``NoResultFound: No row was found for one()`` error.
You'll see an interactive traceback facility provided
by :term:`pyramid_debugtoolbar`.
diff --git a/docs/tutorials/wiki2/design.rst b/docs/tutorials/wiki2/design.rst
index 6e41e00aa..c56d7fecf 100644
--- a/docs/tutorials/wiki2/design.rst
+++ b/docs/tutorials/wiki2/design.rst
@@ -9,7 +9,7 @@ tutorial.
Overall
-------
-We choose to use ``reStructuredText`` markup in the wiki text. Translation
+We choose to use :term:`reStructuredText` markup in the wiki text. Translation
from reStructuredText to HTML is provided by the widely used ``docutils``
Python module. We will add this module in the dependency list on the project
``setup.py`` file.
diff --git a/docs/tutorials/wiki2/index.rst b/docs/tutorials/wiki2/index.rst
index bbc2fb96e..0a614cb23 100644
--- a/docs/tutorials/wiki2/index.rst
+++ b/docs/tutorials/wiki2/index.rst
@@ -9,9 +9,9 @@ tutorial is finished, the developer will have created a basic Wiki
application with authentication.
For cut and paste purposes, the source code for all stages of this
-tutorial can be browsed at
-`https://github.com/Pylons/pyramid/tree/1.3-branch/docs/tutorials/wiki2/src
-<https://github.com/Pylons/pyramid/tree/1.3-branch/docs/tutorials/wiki2/src>`_.
+tutorial can be browsed on GitHub at `docs/tutorials/wiki2/src
+<https://github.com/Pylons/pyramid/tree/master/docs/tutorials/wiki2/src>`_,
+which corresponds to the same location if you have Pyramid sources.
.. toctree::
:maxdepth: 2
diff --git a/docs/tutorials/wiki2/installation.rst b/docs/tutorials/wiki2/installation.rst
index 6589a1557..9fa01d513 100644
--- a/docs/tutorials/wiki2/installation.rst
+++ b/docs/tutorials/wiki2/installation.rst
@@ -2,30 +2,22 @@
Installation
============
-This tutorial assumes that Python and virtualenv are already installed
-and working in your system. If you need help setting this up, you should
-refer to the chapters on :ref:`installing_chapter`.
-
Preparation
===========
-Please take the following steps to prepare for the tutorial. The
-steps are slightly different depending on whether you're using UNIX or
-Windows.
+Follow the steps in :ref:`installing_chapter`, but name the virtualenv
+directory ``pyramidtut``.
Preparation, UNIX
-----------------
#. Install SQLite3 and its development packages if you don't already
have them installed. Usually this is via your system's package
- manager. For example, on a Debian Linux system, do ``sudo apt-get
- install libsqlite3-dev``.
-
-#. Use your Python's virtualenv to make a workspace:
+ manager. On a Debian system, this would be:
.. code-block:: text
- $ path/to/my/Python-2.6/bin/virtualenv --no-site-packages pyramidtut
+ $ sudo apt-get install libsqlite3-dev
#. Switch to the ``pyramidtut`` directory:
@@ -33,35 +25,16 @@ Preparation, UNIX
$ cd pyramidtut
-#. Use ``easy_install`` to get :app:`Pyramid` and its direct
- dependencies installed:
-
- .. code-block:: text
-
- $ bin/easy_install pyramid
Preparation, Windows
--------------------
-#. Use your Python's virtualenv to make a workspace:
-
- .. code-block:: text
-
- c:\> c:\Python26\Scripts\virtualenv --no-site-packages pyramidtut
-
#. Switch to the ``pyramidtut`` directory:
.. code-block:: text
c:\> cd pyramidtut
-#. Use ``easy_install`` to get :app:`Pyramid` and its direct
- dependencies installed:
-
- .. code-block:: text
-
- c:\pyramidtut> Scripts\easy_install pyramid
-
.. _sql_making_a_project:
Making a Project
@@ -93,14 +66,17 @@ On Windows:
startup problems, try putting both the virtualenv 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`` command. In order to do so, cd to the "tutorial"
+``setup.py develop`` command. In order to do so, cd to the `tutorial`
directory you created in :ref:`sql_making_a_project`, and run the
-"setup.py develop" command using virtualenv Python interpreter.
+``setup.py develop`` command using the virtualenv Python interpreter.
On UNIX:
@@ -158,8 +134,8 @@ test`` does but provides additional "coverage" information, exposing
which lines of your project are "covered" (or not covered) by the
tests.
-To get this functionality working, we'll need to install a couple of
-other packages into our ``virtualenv``: ``nose`` and ``coverage``:
+To get this functionality working, we'll need to install the ``nose`` and
+``coverage`` packages into our ``virtualenv``:
On UNIX:
@@ -186,7 +162,7 @@ On Windows:
.. code-block:: text
- c:\pyramidtut\tutorial> ..\Scripts\nosetests --cover-package=tutorial ^
+ c:\pyramidtut\tutorial> ..\Scripts\nosetests --cover-package=tutorial \
--cover-erase --with-coverage
If successful, you will see output something like this::
@@ -208,6 +184,9 @@ If successful, you will see output something like this::
Looks like our package doesn't quite have 100% test coverage.
+
+.. _initialize_db_wiki2:
+
Initializing the Database
=========================
@@ -303,6 +282,9 @@ the following assumptions:
- you are willing to use :term:`url dispatch` to map URLs to code.
+- you want to use ``ZopeTransactionExtension`` and ``pyramid_tm`` to scope
+ sessions to requests
+
.. note::
:app:`Pyramid` supports any persistent storage mechanism (e.g. object
diff --git a/docs/tutorials/wiki2/src/authorization/README.txt b/docs/tutorials/wiki2/src/authorization/README.txt
index 6f851e9b7..141851285 100644
--- a/docs/tutorials/wiki2/src/authorization/README.txt
+++ b/docs/tutorials/wiki2/src/authorization/README.txt
@@ -1 +1,14 @@
tutorial README
+==================
+
+Getting Started
+---------------
+
+- cd <directory containing this file>
+
+- $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/authorization/development.ini b/docs/tutorials/wiki2/src/authorization/development.ini
index eb2f878c5..a9d53b296 100644
--- a/docs/tutorials/wiki2/src/authorization/development.ini
+++ b/docs/tutorials/wiki2/src/authorization/development.ini
@@ -1,3 +1,8 @@
+###
+# app configuration
+# http://docs.pylonsproject.org/projects/pyramid/en/latest/narr/environment.html
+###
+
[app:main]
use = egg:tutorial
@@ -12,12 +17,23 @@ pyramid.includes =
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 = 0.0.0.0
port = 6543
-# Begin logging configuration
+###
+# logging configuration
+# http://docs.pylonsproject.org/projects/pyramid/en/latest/narr/logging.html
+###
[loggers]
keys = root, tutorial, sqlalchemy
@@ -53,5 +69,3 @@ formatter = generic
[formatter_generic]
format = %(asctime)s %(levelname)-5.5s [%(name)s][%(threadName)s] %(message)s
-
-# End logging configuration
diff --git a/docs/tutorials/wiki2/src/authorization/setup.py b/docs/tutorials/wiki2/src/authorization/setup.py
index 2fd051927..36668dd33 100644
--- a/docs/tutorials/wiki2/src/authorization/setup.py
+++ b/docs/tutorials/wiki2/src/authorization/setup.py
@@ -13,17 +13,17 @@ requires = [
'pyramid_tm',
'pyramid_debugtoolbar',
'zope.sqlalchemy',
- 'docutils',
'waitress',
+ 'docutils',
]
setup(name='tutorial',
version='0.0',
description='tutorial',
- long_description=README + '\n\n' + CHANGES,
+ long_description=README + '\n\n' + CHANGES,
classifiers=[
"Programming Language :: Python",
- "Framework :: Pylons",
+ "Framework :: Pyramid",
"Topic :: Internet :: WWW/HTTP",
"Topic :: Internet :: WWW/HTTP :: WSGI :: Application",
],
@@ -35,8 +35,8 @@ setup(name='tutorial',
include_package_data=True,
zip_safe=False,
test_suite='tutorial',
- install_requires = requires,
- entry_points = """\
+ install_requires=requires,
+ entry_points="""\
[paste.app_factory]
main = tutorial:main
[console_scripts]
diff --git a/docs/tutorials/wiki2/src/authorization/tutorial/__init__.py b/docs/tutorials/wiki2/src/authorization/tutorial/__init__.py
index 76071173a..d08e55bf9 100644
--- a/docs/tutorials/wiki2/src/authorization/tutorial/__init__.py
+++ b/docs/tutorials/wiki2/src/authorization/tutorial/__init__.py
@@ -11,6 +11,7 @@ from .models import (
Base,
)
+
def main(global_config, **settings):
""" This function returns a Pyramid WSGI application.
"""
@@ -33,4 +34,3 @@ def main(global_config, **settings):
config.add_route('edit_page', '/{pagename}/edit_page')
config.scan()
return config.make_wsgi_app()
-
diff --git a/docs/tutorials/wiki2/src/authorization/tutorial/models.py b/docs/tutorials/wiki2/src/authorization/tutorial/models.py
index c3bdcbea5..91e5a0019 100644
--- a/docs/tutorials/wiki2/src/authorization/tutorial/models.py
+++ b/docs/tutorials/wiki2/src/authorization/tutorial/models.py
@@ -21,6 +21,7 @@ from zope.sqlalchemy import ZopeTransactionExtension
DBSession = scoped_session(sessionmaker(extension=ZopeTransactionExtension()))
Base = declarative_base()
+
class Page(Base):
""" The SQLAlchemy declarative model class for a Page object. """
__tablename__ = 'pages'
diff --git a/docs/tutorials/wiki2/src/authorization/tutorial/scripts/initializedb.py b/docs/tutorials/wiki2/src/authorization/tutorial/scripts/initializedb.py
index 03188e8ad..092e359ce 100644
--- a/docs/tutorials/wiki2/src/authorization/tutorial/scripts/initializedb.py
+++ b/docs/tutorials/wiki2/src/authorization/tutorial/scripts/initializedb.py
@@ -15,12 +15,14 @@ from ..models import (
Base,
)
+
def usage(argv):
cmd = os.path.basename(argv[0])
print('usage: %s <config_uri>\n'
- '(example: "%s development.ini")' % (cmd, cmd))
+ '(example: "%s development.ini")' % (cmd, cmd))
sys.exit(1)
+
def main(argv=sys.argv):
if len(argv) != 2:
usage(argv)
diff --git a/docs/tutorials/wiki2/src/authorization/tutorial/tests.py b/docs/tutorials/wiki2/src/authorization/tutorial/tests.py
index 31d2dc6d5..5dcee127b 100644
--- a/docs/tutorials/wiki2/src/authorization/tutorial/tests.py
+++ b/docs/tutorials/wiki2/src/authorization/tutorial/tests.py
@@ -1,5 +1,6 @@
import unittest
import transaction
+
from pyramid import testing
def _initTestingDB():
diff --git a/docs/tutorials/wiki2/src/basiclayout/README.txt b/docs/tutorials/wiki2/src/basiclayout/README.txt
index 6f851e9b7..141851285 100644
--- a/docs/tutorials/wiki2/src/basiclayout/README.txt
+++ b/docs/tutorials/wiki2/src/basiclayout/README.txt
@@ -1 +1,14 @@
tutorial README
+==================
+
+Getting Started
+---------------
+
+- cd <directory containing this file>
+
+- $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/basiclayout/development.ini b/docs/tutorials/wiki2/src/basiclayout/development.ini
index eb2f878c5..a9d53b296 100644
--- a/docs/tutorials/wiki2/src/basiclayout/development.ini
+++ b/docs/tutorials/wiki2/src/basiclayout/development.ini
@@ -1,3 +1,8 @@
+###
+# app configuration
+# http://docs.pylonsproject.org/projects/pyramid/en/latest/narr/environment.html
+###
+
[app:main]
use = egg:tutorial
@@ -12,12 +17,23 @@ pyramid.includes =
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 = 0.0.0.0
port = 6543
-# Begin logging configuration
+###
+# logging configuration
+# http://docs.pylonsproject.org/projects/pyramid/en/latest/narr/logging.html
+###
[loggers]
keys = root, tutorial, sqlalchemy
@@ -53,5 +69,3 @@ formatter = generic
[formatter_generic]
format = %(asctime)s %(levelname)-5.5s [%(name)s][%(threadName)s] %(message)s
-
-# End logging configuration
diff --git a/docs/tutorials/wiki2/src/basiclayout/production.ini b/docs/tutorials/wiki2/src/basiclayout/production.ini
index 4684d2f7a..fa94c1b3e 100644
--- a/docs/tutorials/wiki2/src/basiclayout/production.ini
+++ b/docs/tutorials/wiki2/src/basiclayout/production.ini
@@ -1,3 +1,8 @@
+###
+# app configuration
+# http://docs.pylonsproject.org/projects/pyramid/en/latest/narr/environment.html
+###
+
[app:main]
use = egg:tutorial
@@ -16,7 +21,10 @@ use = egg:waitress#main
host = 0.0.0.0
port = 6543
-# Begin logging configuration
+###
+# logging configuration
+# http://docs.pylonsproject.org/projects/pyramid/en/latest/narr/logging.html
+###
[loggers]
keys = root, tutorial, sqlalchemy
@@ -52,5 +60,3 @@ formatter = generic
[formatter_generic]
format = %(asctime)s %(levelname)-5.5s [%(name)s][%(threadName)s] %(message)s
-
-# End logging configuration
diff --git a/docs/tutorials/wiki2/src/basiclayout/setup.py b/docs/tutorials/wiki2/src/basiclayout/setup.py
index 050de7299..a09bf756a 100644
--- a/docs/tutorials/wiki2/src/basiclayout/setup.py
+++ b/docs/tutorials/wiki2/src/basiclayout/setup.py
@@ -19,10 +19,10 @@ requires = [
setup(name='tutorial',
version='0.0',
description='tutorial',
- long_description=README + '\n\n' + CHANGES,
+ long_description=README + '\n\n' + CHANGES,
classifiers=[
"Programming Language :: Python",
- "Framework :: Pylons",
+ "Framework :: Pyramid",
"Topic :: Internet :: WWW/HTTP",
"Topic :: Internet :: WWW/HTTP :: WSGI :: Application",
],
@@ -34,12 +34,11 @@ setup(name='tutorial',
include_package_data=True,
zip_safe=False,
test_suite='tutorial',
- install_requires = requires,
- entry_points = """\
+ install_requires=requires,
+ entry_points="""\
[paste.app_factory]
main = tutorial:main
[console_scripts]
initialize_tutorial_db = tutorial.scripts.initializedb:main
""",
)
-
diff --git a/docs/tutorials/wiki2/src/basiclayout/tutorial/__init__.py b/docs/tutorials/wiki2/src/basiclayout/tutorial/__init__.py
index e39f619ed..aac7c5e69 100644
--- a/docs/tutorials/wiki2/src/basiclayout/tutorial/__init__.py
+++ b/docs/tutorials/wiki2/src/basiclayout/tutorial/__init__.py
@@ -6,6 +6,7 @@ from .models import (
Base,
)
+
def main(global_config, **settings):
""" This function returns a Pyramid WSGI application.
"""
@@ -17,4 +18,3 @@ def main(global_config, **settings):
config.add_route('home', '/')
config.scan()
return config.make_wsgi_app()
-
diff --git a/docs/tutorials/wiki2/src/basiclayout/tutorial/models.py b/docs/tutorials/wiki2/src/basiclayout/tutorial/models.py
index b6ac15429..aeeb9df64 100644
--- a/docs/tutorials/wiki2/src/basiclayout/tutorial/models.py
+++ b/docs/tutorials/wiki2/src/basiclayout/tutorial/models.py
@@ -16,6 +16,7 @@ from zope.sqlalchemy import ZopeTransactionExtension
DBSession = scoped_session(sessionmaker(extension=ZopeTransactionExtension()))
Base = declarative_base()
+
class MyModel(Base):
__tablename__ = 'models'
id = Column(Integer, primary_key=True)
@@ -25,4 +26,3 @@ class MyModel(Base):
def __init__(self, name, value):
self.name = name
self.value = value
-
diff --git a/docs/tutorials/wiki2/src/basiclayout/tutorial/scripts/initializedb.py b/docs/tutorials/wiki2/src/basiclayout/tutorial/scripts/initializedb.py
index 0e828465f..66feb3008 100644
--- a/docs/tutorials/wiki2/src/basiclayout/tutorial/scripts/initializedb.py
+++ b/docs/tutorials/wiki2/src/basiclayout/tutorial/scripts/initializedb.py
@@ -15,12 +15,14 @@ from ..models import (
Base,
)
+
def usage(argv):
cmd = os.path.basename(argv[0])
print('usage: %s <config_uri>\n'
- '(example: "%s development.ini")' % (cmd, cmd))
+ '(example: "%s development.ini")' % (cmd, cmd))
sys.exit(1)
+
def main(argv=sys.argv):
if len(argv) != 2:
usage(argv)
diff --git a/docs/tutorials/wiki2/src/basiclayout/tutorial/templates/mytemplate.pt b/docs/tutorials/wiki2/src/basiclayout/tutorial/templates/mytemplate.pt
index fbfa9870b..15ea6614f 100644
--- a/docs/tutorials/wiki2/src/basiclayout/tutorial/templates/mytemplate.pt
+++ b/docs/tutorials/wiki2/src/basiclayout/tutorial/templates/mytemplate.pt
@@ -70,7 +70,7 @@
</div>
</div>
<div id="footer">
- <div class="footer">&copy; Copyright 2008-2011, Agendaless Consulting.</div>
+ <div class="footer">&copy; Copyright 2008-2012, Agendaless Consulting.</div>
</div>
</body>
</html>
diff --git a/docs/tutorials/wiki2/src/basiclayout/tutorial/tests.py b/docs/tutorials/wiki2/src/basiclayout/tutorial/tests.py
index 653d061e4..57a775e0a 100644
--- a/docs/tutorials/wiki2/src/basiclayout/tutorial/tests.py
+++ b/docs/tutorials/wiki2/src/basiclayout/tutorial/tests.py
@@ -5,6 +5,7 @@ from pyramid import testing
from .models import DBSession
+
class TestMyView(unittest.TestCase):
def setUp(self):
self.config = testing.setUp()
diff --git a/docs/tutorials/wiki2/src/basiclayout/tutorial/views.py b/docs/tutorials/wiki2/src/basiclayout/tutorial/views.py
index 3e6abf2c2..4cfcae4af 100644
--- a/docs/tutorials/wiki2/src/basiclayout/tutorial/views.py
+++ b/docs/tutorials/wiki2/src/basiclayout/tutorial/views.py
@@ -1,11 +1,35 @@
+from pyramid.response import Response
from pyramid.view import view_config
+from sqlalchemy.exc import DBAPIError
+
from .models import (
DBSession,
MyModel,
)
+
@view_config(route_name='home', renderer='templates/mytemplate.pt')
def my_view(request):
- one = DBSession.query(MyModel).filter(MyModel.name=='one').first()
- return {'one':one, 'project':'tutorial'}
+ try:
+ one = DBSession.query(MyModel).filter(MyModel.name == 'one').first()
+ except DBAPIError:
+ return Response(conn_err_msg, content_type='text/plain', status_int=500)
+ return {'one': one, 'project': 'tutorial'}
+
+conn_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/models/README.txt b/docs/tutorials/wiki2/src/models/README.txt
index 6f851e9b7..141851285 100644
--- a/docs/tutorials/wiki2/src/models/README.txt
+++ b/docs/tutorials/wiki2/src/models/README.txt
@@ -1 +1,14 @@
tutorial README
+==================
+
+Getting Started
+---------------
+
+- cd <directory containing this file>
+
+- $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/models/development.ini b/docs/tutorials/wiki2/src/models/development.ini
index eb2f878c5..a9d53b296 100644
--- a/docs/tutorials/wiki2/src/models/development.ini
+++ b/docs/tutorials/wiki2/src/models/development.ini
@@ -1,3 +1,8 @@
+###
+# app configuration
+# http://docs.pylonsproject.org/projects/pyramid/en/latest/narr/environment.html
+###
+
[app:main]
use = egg:tutorial
@@ -12,12 +17,23 @@ pyramid.includes =
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 = 0.0.0.0
port = 6543
-# Begin logging configuration
+###
+# logging configuration
+# http://docs.pylonsproject.org/projects/pyramid/en/latest/narr/logging.html
+###
[loggers]
keys = root, tutorial, sqlalchemy
@@ -53,5 +69,3 @@ formatter = generic
[formatter_generic]
format = %(asctime)s %(levelname)-5.5s [%(name)s][%(threadName)s] %(message)s
-
-# End logging configuration
diff --git a/docs/tutorials/wiki2/src/models/setup.py b/docs/tutorials/wiki2/src/models/setup.py
index 050de7299..a09bf756a 100644
--- a/docs/tutorials/wiki2/src/models/setup.py
+++ b/docs/tutorials/wiki2/src/models/setup.py
@@ -19,10 +19,10 @@ requires = [
setup(name='tutorial',
version='0.0',
description='tutorial',
- long_description=README + '\n\n' + CHANGES,
+ long_description=README + '\n\n' + CHANGES,
classifiers=[
"Programming Language :: Python",
- "Framework :: Pylons",
+ "Framework :: Pyramid",
"Topic :: Internet :: WWW/HTTP",
"Topic :: Internet :: WWW/HTTP :: WSGI :: Application",
],
@@ -34,12 +34,11 @@ setup(name='tutorial',
include_package_data=True,
zip_safe=False,
test_suite='tutorial',
- install_requires = requires,
- entry_points = """\
+ install_requires=requires,
+ entry_points="""\
[paste.app_factory]
main = tutorial:main
[console_scripts]
initialize_tutorial_db = tutorial.scripts.initializedb:main
""",
)
-
diff --git a/docs/tutorials/wiki2/src/models/tutorial/__init__.py b/docs/tutorials/wiki2/src/models/tutorial/__init__.py
index e39f619ed..aac7c5e69 100644
--- a/docs/tutorials/wiki2/src/models/tutorial/__init__.py
+++ b/docs/tutorials/wiki2/src/models/tutorial/__init__.py
@@ -6,6 +6,7 @@ from .models import (
Base,
)
+
def main(global_config, **settings):
""" This function returns a Pyramid WSGI application.
"""
@@ -17,4 +18,3 @@ def main(global_config, **settings):
config.add_route('home', '/')
config.scan()
return config.make_wsgi_app()
-
diff --git a/docs/tutorials/wiki2/src/models/tutorial/models.py b/docs/tutorials/wiki2/src/models/tutorial/models.py
index 499396c5b..9a078d757 100644
--- a/docs/tutorials/wiki2/src/models/tutorial/models.py
+++ b/docs/tutorials/wiki2/src/models/tutorial/models.py
@@ -16,6 +16,7 @@ from zope.sqlalchemy import ZopeTransactionExtension
DBSession = scoped_session(sessionmaker(extension=ZopeTransactionExtension()))
Base = declarative_base()
+
class Page(Base):
""" The SQLAlchemy declarative model class for a Page object. """
__tablename__ = 'pages'
@@ -26,4 +27,3 @@ class Page(Base):
def __init__(self, name, data):
self.name = name
self.data = data
-
diff --git a/docs/tutorials/wiki2/src/models/tutorial/scripts/initializedb.py b/docs/tutorials/wiki2/src/models/tutorial/scripts/initializedb.py
index 03188e8ad..092e359ce 100644
--- a/docs/tutorials/wiki2/src/models/tutorial/scripts/initializedb.py
+++ b/docs/tutorials/wiki2/src/models/tutorial/scripts/initializedb.py
@@ -15,12 +15,14 @@ from ..models import (
Base,
)
+
def usage(argv):
cmd = os.path.basename(argv[0])
print('usage: %s <config_uri>\n'
- '(example: "%s development.ini")' % (cmd, cmd))
+ '(example: "%s development.ini")' % (cmd, cmd))
sys.exit(1)
+
def main(argv=sys.argv):
if len(argv) != 2:
usage(argv)
diff --git a/docs/tutorials/wiki2/src/models/tutorial/tests.py b/docs/tutorials/wiki2/src/models/tutorial/tests.py
index 653d061e4..57a775e0a 100644
--- a/docs/tutorials/wiki2/src/models/tutorial/tests.py
+++ b/docs/tutorials/wiki2/src/models/tutorial/tests.py
@@ -5,6 +5,7 @@ from pyramid import testing
from .models import DBSession
+
class TestMyView(unittest.TestCase):
def setUp(self):
self.config = testing.setUp()
diff --git a/docs/tutorials/wiki2/src/models/tutorial/views.py b/docs/tutorials/wiki2/src/models/tutorial/views.py
index 3e6abf2c2..4cfcae4af 100644
--- a/docs/tutorials/wiki2/src/models/tutorial/views.py
+++ b/docs/tutorials/wiki2/src/models/tutorial/views.py
@@ -1,11 +1,35 @@
+from pyramid.response import Response
from pyramid.view import view_config
+from sqlalchemy.exc import DBAPIError
+
from .models import (
DBSession,
MyModel,
)
+
@view_config(route_name='home', renderer='templates/mytemplate.pt')
def my_view(request):
- one = DBSession.query(MyModel).filter(MyModel.name=='one').first()
- return {'one':one, 'project':'tutorial'}
+ try:
+ one = DBSession.query(MyModel).filter(MyModel.name == 'one').first()
+ except DBAPIError:
+ return Response(conn_err_msg, content_type='text/plain', status_int=500)
+ return {'one': one, 'project': 'tutorial'}
+
+conn_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/tests/README.txt b/docs/tutorials/wiki2/src/tests/README.txt
index 6f851e9b7..141851285 100644
--- a/docs/tutorials/wiki2/src/tests/README.txt
+++ b/docs/tutorials/wiki2/src/tests/README.txt
@@ -1 +1,14 @@
tutorial README
+==================
+
+Getting Started
+---------------
+
+- cd <directory containing this file>
+
+- $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/tests/development.ini b/docs/tutorials/wiki2/src/tests/development.ini
index eb2f878c5..a9d53b296 100644
--- a/docs/tutorials/wiki2/src/tests/development.ini
+++ b/docs/tutorials/wiki2/src/tests/development.ini
@@ -1,3 +1,8 @@
+###
+# app configuration
+# http://docs.pylonsproject.org/projects/pyramid/en/latest/narr/environment.html
+###
+
[app:main]
use = egg:tutorial
@@ -12,12 +17,23 @@ pyramid.includes =
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 = 0.0.0.0
port = 6543
-# Begin logging configuration
+###
+# logging configuration
+# http://docs.pylonsproject.org/projects/pyramid/en/latest/narr/logging.html
+###
[loggers]
keys = root, tutorial, sqlalchemy
@@ -53,5 +69,3 @@ formatter = generic
[formatter_generic]
format = %(asctime)s %(levelname)-5.5s [%(name)s][%(threadName)s] %(message)s
-
-# End logging configuration
diff --git a/docs/tutorials/wiki2/src/tests/setup.py b/docs/tutorials/wiki2/src/tests/setup.py
index 0f58d8a18..3c2961fcc 100644
--- a/docs/tutorials/wiki2/src/tests/setup.py
+++ b/docs/tutorials/wiki2/src/tests/setup.py
@@ -21,10 +21,10 @@ requires = [
setup(name='tutorial',
version='0.0',
description='tutorial',
- long_description=README + '\n\n' + CHANGES,
+ long_description=README + '\n\n' + CHANGES,
classifiers=[
"Programming Language :: Python",
- "Framework :: Pylons",
+ "Framework :: Pyramid",
"Topic :: Internet :: WWW/HTTP",
"Topic :: Internet :: WWW/HTTP :: WSGI :: Application",
],
@@ -36,8 +36,8 @@ setup(name='tutorial',
include_package_data=True,
zip_safe=False,
test_suite='tutorial',
- install_requires = requires,
- entry_points = """\
+ install_requires=requires,
+ entry_points="""\
[paste.app_factory]
main = tutorial:main
[console_scripts]
diff --git a/docs/tutorials/wiki2/src/tests/tutorial/__init__.py b/docs/tutorials/wiki2/src/tests/tutorial/__init__.py
index 76071173a..d08e55bf9 100644
--- a/docs/tutorials/wiki2/src/tests/tutorial/__init__.py
+++ b/docs/tutorials/wiki2/src/tests/tutorial/__init__.py
@@ -11,6 +11,7 @@ from .models import (
Base,
)
+
def main(global_config, **settings):
""" This function returns a Pyramid WSGI application.
"""
@@ -33,4 +34,3 @@ def main(global_config, **settings):
config.add_route('edit_page', '/{pagename}/edit_page')
config.scan()
return config.make_wsgi_app()
-
diff --git a/docs/tutorials/wiki2/src/tests/tutorial/models.py b/docs/tutorials/wiki2/src/tests/tutorial/models.py
index c3bdcbea5..91e5a0019 100644
--- a/docs/tutorials/wiki2/src/tests/tutorial/models.py
+++ b/docs/tutorials/wiki2/src/tests/tutorial/models.py
@@ -21,6 +21,7 @@ from zope.sqlalchemy import ZopeTransactionExtension
DBSession = scoped_session(sessionmaker(extension=ZopeTransactionExtension()))
Base = declarative_base()
+
class Page(Base):
""" The SQLAlchemy declarative model class for a Page object. """
__tablename__ = 'pages'
diff --git a/docs/tutorials/wiki2/src/tests/tutorial/scripts/initializedb.py b/docs/tutorials/wiki2/src/tests/tutorial/scripts/initializedb.py
index 03188e8ad..092e359ce 100644
--- a/docs/tutorials/wiki2/src/tests/tutorial/scripts/initializedb.py
+++ b/docs/tutorials/wiki2/src/tests/tutorial/scripts/initializedb.py
@@ -15,12 +15,14 @@ from ..models import (
Base,
)
+
def usage(argv):
cmd = os.path.basename(argv[0])
print('usage: %s <config_uri>\n'
- '(example: "%s development.ini")' % (cmd, cmd))
+ '(example: "%s development.ini")' % (cmd, cmd))
sys.exit(1)
+
def main(argv=sys.argv):
if len(argv) != 2:
usage(argv)
diff --git a/docs/tutorials/wiki2/src/tests/tutorial/tests.py b/docs/tutorials/wiki2/src/tests/tutorial/tests.py
index 659862a09..3e96d0a82 100644
--- a/docs/tutorials/wiki2/src/tests/tutorial/tests.py
+++ b/docs/tutorials/wiki2/src/tests/tutorial/tests.py
@@ -1,7 +1,9 @@
import unittest
import transaction
+
from pyramid import testing
+
def _initTestingDB():
from sqlalchemy import create_engine
from tutorial.models import (
@@ -17,6 +19,7 @@ def _initTestingDB():
DBSession.add(model)
return DBSession
+
def _registerRoutes(config):
config.add_route('view_page', '{pagename}')
config.add_route('edit_page', '{pagename}/edit_page')
@@ -43,6 +46,7 @@ class PageModelTests(unittest.TestCase):
self.assertEqual(instance.name, 'SomeName')
self.assertEqual(instance.data, 'some data')
+
class ViewWikiTests(unittest.TestCase):
def setUp(self):
self.config = testing.setUp()
@@ -60,6 +64,7 @@ class ViewWikiTests(unittest.TestCase):
response = self._callFUT(request)
self.assertEqual(response.location, 'http://example.com/FrontPage')
+
class ViewPageTests(unittest.TestCase):
def setUp(self):
self.session = _initTestingDB()
@@ -93,6 +98,7 @@ class ViewPageTests(unittest.TestCase):
self.assertEqual(info['edit_url'],
'http://example.com/IDoExist/edit_page')
+
class AddPageTests(unittest.TestCase):
def setUp(self):
self.session = _initTestingDB()
@@ -125,6 +131,7 @@ class AddPageTests(unittest.TestCase):
page = self.session.query(Page).filter_by(name='AnotherPage').one()
self.assertEqual(page.data, 'Hello yo!')
+
class EditPageTests(unittest.TestCase):
def setUp(self):
self.session = _initTestingDB()
@@ -162,6 +169,7 @@ class EditPageTests(unittest.TestCase):
self.assertEqual(response.location, 'http://example.com/abc')
self.assertEqual(page.data, 'Hello yo!')
+
class FunctionalTests(unittest.TestCase):
viewer_login = '/login?login=viewer&password=viewer' \
diff --git a/docs/tutorials/wiki2/src/tests/tutorial/views.py b/docs/tutorials/wiki2/src/tests/tutorial/views.py
index 42ac0eb7f..0d085b0e2 100644
--- a/docs/tutorials/wiki2/src/tests/tutorial/views.py
+++ b/docs/tutorials/wiki2/src/tests/tutorial/views.py
@@ -37,14 +37,13 @@ def view_wiki(request):
permission='view')
def view_page(request):
pagename = request.matchdict['pagename']
- session = DBSession()
- page = session.query(Page).filter_by(name=pagename).first()
+ page = DBSession.query(Page).filter_by(name=pagename).first()
if page is None:
return HTTPNotFound('No such page')
def check(match):
word = match.group(1)
- exists = session.query(Page).filter_by(name=word).all()
+ exists = DBSession.query(Page).filter_by(name=word).all()
if exists:
view_url = request.route_url('view_page', pagename=word)
return '<a href="%s">%s</a>' % (view_url, word)
@@ -63,10 +62,9 @@ def view_page(request):
def add_page(request):
pagename = request.matchdict['pagename']
if 'form.submitted' in request.params:
- session = DBSession()
body = request.params['body']
page = Page(pagename, body)
- session.add(page)
+ DBSession.add(page)
return HTTPFound(location = request.route_url('view_page',
pagename=pagename))
save_url = request.route_url('add_page', pagename=pagename)
@@ -78,11 +76,10 @@ def add_page(request):
permission='edit')
def edit_page(request):
pagename = request.matchdict['pagename']
- session = DBSession()
- page = session.query(Page).filter_by(name=pagename).one()
+ page = DBSession.query(Page).filter_by(name=pagename).one()
if 'form.submitted' in request.params:
page.data = request.params['body']
- session.add(page)
+ DBSession.add(page)
return HTTPFound(location = request.route_url('view_page',
pagename=pagename))
return dict(
diff --git a/docs/tutorials/wiki2/src/views/README.txt b/docs/tutorials/wiki2/src/views/README.txt
index 6f851e9b7..141851285 100644
--- a/docs/tutorials/wiki2/src/views/README.txt
+++ b/docs/tutorials/wiki2/src/views/README.txt
@@ -1 +1,14 @@
tutorial README
+==================
+
+Getting Started
+---------------
+
+- cd <directory containing this file>
+
+- $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/views/development.ini b/docs/tutorials/wiki2/src/views/development.ini
index eb2f878c5..a9d53b296 100644
--- a/docs/tutorials/wiki2/src/views/development.ini
+++ b/docs/tutorials/wiki2/src/views/development.ini
@@ -1,3 +1,8 @@
+###
+# app configuration
+# http://docs.pylonsproject.org/projects/pyramid/en/latest/narr/environment.html
+###
+
[app:main]
use = egg:tutorial
@@ -12,12 +17,23 @@ pyramid.includes =
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 = 0.0.0.0
port = 6543
-# Begin logging configuration
+###
+# logging configuration
+# http://docs.pylonsproject.org/projects/pyramid/en/latest/narr/logging.html
+###
[loggers]
keys = root, tutorial, sqlalchemy
@@ -53,5 +69,3 @@ formatter = generic
[formatter_generic]
format = %(asctime)s %(levelname)-5.5s [%(name)s][%(threadName)s] %(message)s
-
-# End logging configuration
diff --git a/docs/tutorials/wiki2/src/views/setup.py b/docs/tutorials/wiki2/src/views/setup.py
index 34b578e21..36668dd33 100644
--- a/docs/tutorials/wiki2/src/views/setup.py
+++ b/docs/tutorials/wiki2/src/views/setup.py
@@ -20,10 +20,10 @@ requires = [
setup(name='tutorial',
version='0.0',
description='tutorial',
- long_description=README + '\n\n' + CHANGES,
+ long_description=README + '\n\n' + CHANGES,
classifiers=[
"Programming Language :: Python",
- "Framework :: Pylons",
+ "Framework :: Pyramid",
"Topic :: Internet :: WWW/HTTP",
"Topic :: Internet :: WWW/HTTP :: WSGI :: Application",
],
@@ -35,12 +35,11 @@ setup(name='tutorial',
include_package_data=True,
zip_safe=False,
test_suite='tutorial',
- install_requires = requires,
- entry_points = """\
+ install_requires=requires,
+ entry_points="""\
[paste.app_factory]
main = tutorial:main
[console_scripts]
initialize_tutorial_db = tutorial.scripts.initializedb:main
""",
)
-
diff --git a/docs/tutorials/wiki2/src/views/tutorial/__init__.py b/docs/tutorials/wiki2/src/views/tutorial/__init__.py
index 810e92f75..c95bfdbf8 100644
--- a/docs/tutorials/wiki2/src/views/tutorial/__init__.py
+++ b/docs/tutorials/wiki2/src/views/tutorial/__init__.py
@@ -6,6 +6,7 @@ from .models import (
Base,
)
+
def main(global_config, **settings):
""" This function returns a Pyramid WSGI application.
"""
diff --git a/docs/tutorials/wiki2/src/views/tutorial/models.py b/docs/tutorials/wiki2/src/views/tutorial/models.py
index 499396c5b..9a078d757 100644
--- a/docs/tutorials/wiki2/src/views/tutorial/models.py
+++ b/docs/tutorials/wiki2/src/views/tutorial/models.py
@@ -16,6 +16,7 @@ from zope.sqlalchemy import ZopeTransactionExtension
DBSession = scoped_session(sessionmaker(extension=ZopeTransactionExtension()))
Base = declarative_base()
+
class Page(Base):
""" The SQLAlchemy declarative model class for a Page object. """
__tablename__ = 'pages'
@@ -26,4 +27,3 @@ class Page(Base):
def __init__(self, name, data):
self.name = name
self.data = data
-
diff --git a/docs/tutorials/wiki2/src/views/tutorial/scripts/initializedb.py b/docs/tutorials/wiki2/src/views/tutorial/scripts/initializedb.py
index 03188e8ad..092e359ce 100644
--- a/docs/tutorials/wiki2/src/views/tutorial/scripts/initializedb.py
+++ b/docs/tutorials/wiki2/src/views/tutorial/scripts/initializedb.py
@@ -15,12 +15,14 @@ from ..models import (
Base,
)
+
def usage(argv):
cmd = os.path.basename(argv[0])
print('usage: %s <config_uri>\n'
- '(example: "%s development.ini")' % (cmd, cmd))
+ '(example: "%s development.ini")' % (cmd, cmd))
sys.exit(1)
+
def main(argv=sys.argv):
if len(argv) != 2:
usage(argv)
diff --git a/docs/tutorials/wiki2/src/views/tutorial/tests.py b/docs/tutorials/wiki2/src/views/tutorial/tests.py
index 31d2dc6d5..5dcee127b 100644
--- a/docs/tutorials/wiki2/src/views/tutorial/tests.py
+++ b/docs/tutorials/wiki2/src/views/tutorial/tests.py
@@ -1,5 +1,6 @@
import unittest
import transaction
+
from pyramid import testing
def _initTestingDB():
diff --git a/docs/tutorials/wiki2/tests.rst b/docs/tutorials/wiki2/tests.rst
index 6a7cbf62d..83df86b27 100644
--- a/docs/tutorials/wiki2/tests.rst
+++ b/docs/tutorials/wiki2/tests.rst
@@ -6,9 +6,6 @@ We will now add tests for the models and the views and a few functional
tests in the ``tests.py``. Tests ensure that an application works, and
that it continues to work after changes are made in the future.
-The source code for this tutorial stage can be browsed at
-`http://github.com/Pylons/pyramid/tree/1.3-branch/docs/tutorials/wiki2/src/tests/
-<http://github.com/Pylons/pyramid/tree/1.3-branch/docs/tutorials/wiki2/src/tests/>`_.
Testing the Models
diff --git a/docs/whatsnew-1.4.rst b/docs/whatsnew-1.4.rst
index 5da28bb03..34fda5f37 100644
--- a/docs/whatsnew-1.4.rst
+++ b/docs/whatsnew-1.4.rst
@@ -225,6 +225,23 @@ Minor Feature Additions
as it doesn't make sense to assert that a nonexistent view is
execution-permitted. See https://github.com/Pylons/pyramid/issues/299.
+- Small microspeed enhancement which anticipates that a
+ :class:`pyramid.response.Response` object is likely to be returned from a
+ view. Some code is shortcut if the class of the object returned by a view is
+ this class. A similar microoptimization was done to
+ :func:`pyramid.request.Request.is_response`.
+
+- Make it possible to use variable arguments on all ``p*`` commands
+ (``pserve``, ``pshell``, ``pviews``, etc) in the form ``a=1 b=2`` so you can
+ fill in values in parameterized ``.ini`` file, e.g. ``pshell
+ etc/development.ini http_port=8080``.
+
+- In order to allow people to ignore unused arguments to subscriber callables
+ and to normalize the relationship between event subscribers and subscriber
+ predicates, we now allow both subscribers and subscriber predicates to accept
+ only a single ``event`` argument even if they've been subscribed for
+ notifications that involve multiple interfaces.
+
Backwards Incompatibilities
---------------------------