From 0435ccd15f7c7c3960208d0bac413cd8eb42cd56 Mon Sep 17 00:00:00 2001 From: Tshepang Lekhonkhobe Date: Sat, 6 Apr 2013 08:11:45 +0200 Subject: trim commented-out parts of docs/conf.py proposed here: https://groups.google.com/forum/?fromgroups=#!topic/pylons-devel/n2-7zvLWK3E --- docs/conf.py | 91 ++---------------------------------------------------------- 1 file changed, 2 insertions(+), 89 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index 1ddcae08e..33bedc9dd 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -101,39 +101,19 @@ release = version # Else, today_fmt is used as the format for a strftime call. today_fmt = '%B %d, %Y' -# List of documents that shouldn't be included in the build. -#unused_docs = [] - # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. exclude_patterns = ['_themes/README.rst', ] -# List of directories, relative to source directories, that shouldn't be searched -# for source files. -#exclude_dirs = [] - -# The reST default role (used for this markup: `text`) to use for all documents. -#default_role = None - -# If true, '()' will be appended to :func: etc. cross-reference text. -#add_function_parentheses = True - # If true, the current module name will be prepended to all description # unit titles (such as .. function::). add_module_names = False -# If true, sectionauthor and moduleauthor directives will be shown in the -# output. They are ignored by default. -#show_authors = False - # The name of the Pygments (syntax highlighting) style to use. #pygments_style = book and 'bw' or 'tango' if book: pygments_style = 'bw' -# The default language to highlight source code in. -#highlight_language = 'guess' - # Options for HTML output # ----------------------- @@ -169,67 +149,15 @@ html_theme_options = dict( github_url='https://github.com/Pylons/pyramid', # in_progress='true', ) -# The style sheet to use for HTML and HTML Help pages. A file of that name -# must exist either in Sphinx' static/ path, or in one of the custom paths -# given in html_static_path. -#html_style = 'pyramid.css' # The name for this set of Sphinx documents. If None, it defaults to # " v documentation". html_title = 'The Pyramid Web Application Development Framework v%s' % release -# A shorter title for the navigation bar. Default is the same as html_title. -#html_short_title = 'Home' - -# The name of an image file (within the static path) to place at the top of -# the sidebar. -#html_logo = '_static/pyramid.png' - -# The name of an image file (within the static path) to use as favicon of the -# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 -# pixels large. -#html_favicon = '_static/pyramid.ico' - -# Add any paths that contain custom static files (such as style sheets) here, -# relative to this directory. They are copied after the builtin static files, -# so a file named "default.css" will overwrite the builtin "default.css". -#html_static_path = ['_static'] - # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, # using the given strftime format. html_last_updated_fmt = '%b %d, %Y' -# If true, SmartyPants will be used to convert quotes and dashes to -# typographically correct entities. -#html_use_smartypants = True - -# Custom sidebar templates, maps document names to template names. -#html_sidebars = {} - -# Additional templates that should be rendered to pages, maps page names to -# template names. -#html_additional_pages = {} - -# If false, no module index is generated. -#html_use_modindex = True - -# If false, no index is generated. -#html_use_index = True - -# If true, the index is split into individual pages for each letter. -#html_split_index = False - -# If true, the reST sources are included in the HTML build as _sources/. -#html_copy_source = True - -# If true, an OpenSearch description file will be output, and all pages will -# contain a tag referring to it. The value of this option must be the -# base URL from which the finished HTML is served. -#html_use_opensearch = '' - -# If nonempty, this is the file name suffix for HTML files (e.g. ".xhtml"). -#html_file_suffix = '' - # Output file base name for HTML help builder. htmlhelp_basename = 'pyramid' @@ -252,20 +180,10 @@ latex_documents = [ 'Chris McDonough', 'manual'), ] -# The name of an image file (relative to this directory) to place at the top of -# the title page. -#latex_logo = '_static/pylons_small.png' - # For "manual" documents, if this is true, then toplevel headings are parts, # not chapters. latex_use_parts = True -# Additional stuff for the LaTeX preamble. -#latex_preamble = '' - -# Documents to append as an appendix to all manuals. -#latex_appendices = [] - # If false, no module index is generated. latex_use_modindex = False @@ -508,13 +426,6 @@ epub_identifier = '0615445675' # A unique identification for the text. 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 = [] - -# HTML files shat should be inserted after the pages created by sphinx. -# The format is a list of tuples containing the path and title. -#epub_post_files = [] # A list of files that should not be packed into the epub file. epub_exclude_files = ['_static/opensearch.xml', '_static/doctools.js', @@ -524,3 +435,5 @@ epub_exclude_files = ['_static/opensearch.xml', '_static/doctools.js', # The depth of the table of contents in toc.ncx. epub_tocdepth = 3 + +# For a list of all settings, visit http://sphinx-doc.org/config.html. -- cgit v1.2.3 From 44436e1240f497e598de7b316ffaf7b6b8665452 Mon Sep 17 00:00:00 2001 From: Bert JW Regeer Date: Tue, 3 Sep 2013 18:30:56 -0600 Subject: Removed unnecessary side bar with duplicate content The side-bar contained a duplication of code that was already in the main article. Adding a note instead and removing the side-bar provides the same information without nearly as much duplication. --- docs/narr/traversal.rst | 28 ++++++---------------------- 1 file changed, 6 insertions(+), 22 deletions(-) diff --git a/docs/narr/traversal.rst b/docs/narr/traversal.rst index a60c5ba56..fb4adff61 100644 --- a/docs/narr/traversal.rst +++ b/docs/narr/traversal.rst @@ -128,6 +128,12 @@ Here's an example of a simple root factory class: def __init__(self, request): pass +..note:: + For the purpose of understanding traversal, and the contents within + this document, the above Root is an analogue to the default root + factory present in Pyramid. The default root factory is very simple and + not very useful unless using :term:`URL dispatch`. + Here's an example of using this root factory within startup configuration, by passing it to an instance of a :term:`Configurator` named ``config``: @@ -154,28 +160,6 @@ Usually a root factory for a traversal-based application will be more complicated than the above ``Root`` class; in particular it may be associated with a database connection or another persistence mechanism. -.. sidebar:: Emulating the Default Root Factory - - For purposes of understanding the default root factory better, we'll note - that you can emulate the default root factory by using this code as an - explicit root factory in your application setup: - - .. code-block:: python - :linenos: - - class Root(object): - def __init__(self, request): - pass - - config = Configurator(root_factory=Root) - - The default root factory is just a really stupid object that has no - behavior or state. Using :term:`traversal` against an application that - uses the resource tree supplied by the default root resource is not very - interesting, because the default root resource has no children. Its - availability is more useful when you're developing an application using - :term:`URL dispatch`. - .. note:: If the items contained within the resource tree are "persistent" (they -- cgit v1.2.3 From ae5f2b9da9583114f3f5a6f08497e5a248e3e960 Mon Sep 17 00:00:00 2001 From: "Karl O. Pinc" Date: Fri, 27 Sep 2013 20:47:28 -0500 Subject: Docs: Make clear that installation is into the virtual enviornment. --- docs/narr/project.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/narr/project.rst b/docs/narr/project.rst index f3050f805..602f15fef 100644 --- a/docs/narr/project.rst +++ b/docs/narr/project.rst @@ -193,10 +193,10 @@ Elided output from a run of this command on UNIX is shown below: ... Finished processing dependencies for MyProject==0.0 -This will install a :term:`distribution` representing your project into the -interpreter's library set so it can be found by ``import`` statements and by -other console scripts such as ``pserve``, ``pshell``, ``proutes`` and -``pviews``. +This will install a :term:`distribution` representing your project +into the virtual environment interpreter's library set so it can be +found by ``import`` statements and by other console scripts such as +``pserve``, ``pshell``, ``proutes`` and ``pviews``. .. index:: single: running tests -- cgit v1.2.3 From af5fa07ca2fcc48ab357c0db4e1301bb960addca Mon Sep 17 00:00:00 2001 From: Michael Merickel Date: Fri, 27 Sep 2013 23:45:41 -0500 Subject: support a None value in query string parameters --- CHANGES.txt | 10 ++++++++++ pyramid/encode.py | 6 ++++++ pyramid/tests/test_encode.py | 8 ++++++++ 3 files changed, 24 insertions(+) diff --git a/CHANGES.txt b/CHANGES.txt index 8b2210a99..e972c08c3 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -6,6 +6,16 @@ Documentation - Added a "Quick Tutorial" to go with the Quick Tour +Backwards Incompatibilities +--------------------------- + +- The key/values in the ``_query`` parameter of ``request.route_url`` and the + ``query`` parameter of ``request.resource_url`` (and their variants), used + to encode a value of ``None`` as the string ``'None'``, leaving the resulting + query string to be ``a=b&key=None``. The value is now dropped in this + situation, leaving a query string of ``a=b&key``. + See https://github.com/Pylons/pyramid/issues/1119 + 1.5a2 (2013-09-22) ================== diff --git a/pyramid/encode.py b/pyramid/encode.py index 65bc95032..9341f7665 100644 --- a/pyramid/encode.py +++ b/pyramid/encode.py @@ -32,6 +32,10 @@ def urlencode(query, doseq=True): See the Python stdlib documentation for ``urllib.urlencode`` for more information. + + .. versionchanged:: 1.5 + In a key/value pair, if the value is ``None`` then it will be + dropped from the resulting output. """ try: # presumed to be a dictionary @@ -50,6 +54,8 @@ def urlencode(query, doseq=True): x = _enc(x) result += '%s%s=%s' % (prefix, k, x) prefix = '&' + elif v is None: + result += '%s%s' % (prefix, k) else: v = _enc(v) result += '%s%s=%s' % (prefix, k, v) diff --git a/pyramid/tests/test_encode.py b/pyramid/tests/test_encode.py index 736ecb5b3..1e0ecbe20 100644 --- a/pyramid/tests/test_encode.py +++ b/pyramid/tests/test_encode.py @@ -41,6 +41,14 @@ class UrlEncodeTests(unittest.TestCase): result = self._callFUT({'a':1}) self.assertEqual(result, 'a=1') + def test_None_value(self): + result = self._callFUT([('a', None)]) + self.assertEqual(result, 'a') + + def test_None_value_with_prefix(self): + result = self._callFUT([('a', '1'), ('b', None)]) + self.assertEqual(result, 'a=1&b') + class URLQuoteTests(unittest.TestCase): def _callFUT(self, val, safe=''): from pyramid.encode import url_quote -- cgit v1.2.3 From a8cb0406c3096486dd66204aa144cb117dab0890 Mon Sep 17 00:00:00 2001 From: Marius Gedminas Date: Sat, 28 Sep 2013 09:59:09 +0300 Subject: OCD: add back missing ) --- docs/quick_tour.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/quick_tour.rst b/docs/quick_tour.rst index 434dbdad5..1ac5181f3 100644 --- a/docs/quick_tour.rst +++ b/docs/quick_tour.rst @@ -17,7 +17,7 @@ Pyramid is a breeze. Unfortunately "standard" is not so simple in Python. For this Quick Tour, it means: `Python `_, a `virtual environment `_ -(or `virtualenv for Python 2.7 `_, +(or `virtualenv for Python 2.7 `_), and `setuptools `_. As an example, for Python 3.3+ on Linux: -- cgit v1.2.3 From 2323103debf8487d0a0a1ec27580e502d46989e3 Mon Sep 17 00:00:00 2001 From: Steve Piercy Date: Sat, 28 Sep 2013 02:19:27 -0700 Subject: Add versioning to branch master --- docs/narr/install.rst | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/narr/install.rst b/docs/narr/install.rst index f3f736df6..e419a8b20 100644 --- a/docs/narr/install.rst +++ b/docs/narr/install.rst @@ -289,9 +289,9 @@ Installing :app:`Pyramid` Into the Virtual Python Environment After you've got your virtualenv installed, you may install :app:`Pyramid` itself using the following commands: -.. code-block:: text - - $ $VENV/bin/easy_install pyramid +.. parsed-literal:: + + $ $VENV/bin/easy_install "pyramid==\ |release|\ " The ``easy_install`` command will take longer than the previous ones to complete, as it downloads and installs a number of dependencies. @@ -368,9 +368,9 @@ You can use Pyramid on Windows under Python 2 or 3. #. Use ``easy_install`` to get :app:`Pyramid` and its direct dependencies installed: - .. code-block:: text - - c:\env> %VENV%\Scripts\easy_install pyramid + .. parsed-literal:: + + c:\\env> %VENV%\\Scripts\\easy_install "pyramid==\ |release|\ " What Gets Installed ------------------- -- cgit v1.2.3 From 0e142c07da354d858e455c576a625c48559c3353 Mon Sep 17 00:00:00 2001 From: Paul Everitt Date: Sat, 28 Sep 2013 12:13:45 -0400 Subject: Used a parsed-literal to pin the version number on easy_install. --- docs/quick_tour/jinja2/hello_world.jinja2 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/quick_tour/jinja2/hello_world.jinja2 b/docs/quick_tour/jinja2/hello_world.jinja2 index e177744b5..7a902dd3a 100644 --- a/docs/quick_tour/jinja2/hello_world.jinja2 +++ b/docs/quick_tour/jinja2/hello_world.jinja2 @@ -1,4 +1,5 @@ - + + Hello World -- cgit v1.2.3 From ebca905c2a2e1e796f3840baaf154a6d9d695cc4 Mon Sep 17 00:00:00 2001 From: Paul Everitt Date: Sat, 28 Sep 2013 12:14:13 -0400 Subject: Used a parsed-literal to pin the version number on easy_install. --- docs/quick_tour.rst | 14 +++++++------- docs/quick_tutorial/requirements.rst | 24 ++++++++++++------------ 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/docs/quick_tour.rst b/docs/quick_tour.rst index 1ac5181f3..98584e608 100644 --- a/docs/quick_tour.rst +++ b/docs/quick_tour.rst @@ -22,21 +22,21 @@ and `setuptools `_. As an example, for Python 3.3+ on Linux: -.. code-block:: bash +.. parsed-literal:: $ pyvenv env33 $ wget https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py -O - | env33/bin/python - $ env33/bin/easy_install pyramid + $ env33/bin/easy_install "pyramid==\ |release|\ " For Windows: -.. code-block:: posh +.. parsed-literal:: # Use your browser to download: # https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py - c:\> c:\Python33\python -m venv env33 - c:\> env33\Scripts\python ez_setup.py - c:\> env33\Scripts\easy_install pyramid + c:\\> c:\\Python33\\python -m venv env33 + c:\\> env33\\Scripts\\python ez_setup.py + c:\\> env33\\Scripts\\easy_install "pyramid==\ |release|\ " Of course Pyramid runs fine on Python 2.6+, as do the examples in this *Quick Tour*. We're just showing Python 3 a little love (Pyramid had @@ -297,7 +297,7 @@ The only change in our view...point the renderer at the ``.jinja2`` file: Our Jinja2 template is very similar to our previous template: .. literalinclude:: quick_tour/jinja2/hello_world.jinja2 - :language: jinja + :language: html Pyramid's templating add-ons register a new kind of renderer into your application. The renderer registration maps to different kinds of diff --git a/docs/quick_tutorial/requirements.rst b/docs/quick_tutorial/requirements.rst index df63ff912..40e818807 100644 --- a/docs/quick_tutorial/requirements.rst +++ b/docs/quick_tutorial/requirements.rst @@ -94,23 +94,23 @@ and where our virtual environment will reside: Final directory structure. -The commands to do so are as follows: +For Linux, the commands to do so are as follows: .. code-block:: bash # Mac and Linux $ cd ~ - $ mkdir projects - $ cd projects - $ mkdir quick_tutorial - $ cd quick_tutorial + $ mkdir -p projects/quick_tutorial + $ cd projects/quick_tutorial + +For Windows: + +.. code-block:: posh # Windows c:\> cd \ - c:\> mkdir projects - c:\> cd projects - c:\> mkdir quick_tutorial - c:\> cd quick_tutorial + c:\> mkdir projects\quick_tutorial + c:\> cd projects\quick_tutorial In the above figure, your user home directory is represented by ``~``. In your home directory, all of your projects are in the ``projects`` directory. @@ -208,13 +208,13 @@ Install Pyramid We have our Python standard prerequisites out of the way. The Pyramid part is pretty easy: -.. code-block:: bash +.. parsed-literal:: # Mac and Linux - $ $VENV/bin/easy_install pyramid + $ $VENV/bin/easy_install "pyramid==\ |release|\ " # Windows - c:\> %VENV%\Scripts\easy_install pyramid + c:\\> %VENV%\\Scripts\\easy_install "pyramid==\ |release|\ " Our Python virtual environment now has the Pyramid software available. -- cgit v1.2.3 From 84ae800468544650c4a2eaa01a3ac805dafba480 Mon Sep 17 00:00:00 2001 From: "Karl O. Pinc" Date: Mon, 30 Sep 2013 21:35:13 -0500 Subject: CONTRIBUTORS: Add Karl O. Pinc. --- CONTRIBUTORS.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CONTRIBUTORS.txt b/CONTRIBUTORS.txt index 1a5b975d7..bfe22e540 100644 --- a/CONTRIBUTORS.txt +++ b/CONTRIBUTORS.txt @@ -222,3 +222,5 @@ Contributors - Takahiro Fujiwara, 2013/08/28 - Doug Hellmann, 2013/09/06 + +- Karl O. Pinc, 2013/09/27 -- cgit v1.2.3 From bc3de3f5499e39e67e29b6678503f3a14be0b08c Mon Sep 17 00:00:00 2001 From: "Karl O. Pinc" Date: Tue, 1 Oct 2013 00:14:12 -0500 Subject: Docs: project.rst: Match parenthesis & fix punctuation. --- docs/narr/project.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/narr/project.rst b/docs/narr/project.rst index 602f15fef..fc3cac009 100644 --- a/docs/narr/project.rst +++ b/docs/narr/project.rst @@ -974,9 +974,9 @@ named ``views`` instead of within a single ``views.py`` file, you might: - *Move* the existing ``views.py`` file to a file inside the new ``views`` directory named, say, ``blog.py``. -- Create a file within the new ``views`` directory named ``__init__.py`` (it - can be empty, this just tells Python that the ``views`` directory is a - *package*. +- Create a file within the new ``views`` directory named ``__init__.py``. (It + can be empty. This just tells Python that the ``views`` directory is a + *package*.) You can then continue to add view callable functions to the ``blog.py`` module, but you can also add other ``.py`` files which contain view callable -- cgit v1.2.3 From 128d9d6cd92ddd50dfcdf14b12cc94a0902c0df1 Mon Sep 17 00:00:00 2001 From: "Karl O. Pinc" Date: Tue, 1 Oct 2013 00:22:20 -0500 Subject: Docs: project.rst: Note that asset specs must be fully qualifed when moving views into a sub-package. --- docs/narr/project.rst | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/docs/narr/project.rst b/docs/narr/project.rst index fc3cac009..1b98271fb 100644 --- a/docs/narr/project.rst +++ b/docs/narr/project.rst @@ -971,13 +971,16 @@ named ``views`` instead of within a single ``views.py`` file, you might: - Create a ``views`` directory inside your ``myproject`` package directory (the same directory which holds ``views.py``). -- *Move* the existing ``views.py`` file to a file inside the new ``views`` - directory named, say, ``blog.py``. - - Create a file within the new ``views`` directory named ``__init__.py``. (It can be empty. This just tells Python that the ``views`` directory is a *package*.) +- *Move* the existing ``views.py`` file to a file inside the new ``views`` + directory named, say, ``blog.py``. The template :term:`asset + specification`s in ``blog.py`` must now be fully qualified with the + project's package name (``myproject:templates/blog.pt``) since the + ``templates`` directory remains in the ``myproject`` package. + You can then continue to add view callable functions to the ``blog.py`` module, but you can also add other ``.py`` files which contain view callable functions to the ``views`` directory. As long as you use the -- cgit v1.2.3 From ac7d1752e071fb7dadbfbf7f4bd1efadd3052b4f Mon Sep 17 00:00:00 2001 From: "Karl O. Pinc" Date: Tue, 1 Oct 2013 00:44:16 -0500 Subject: Docs: project.rst: Make the sentence more better. --- docs/narr/project.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/narr/project.rst b/docs/narr/project.rst index 1b98271fb..e5da3b5c5 100644 --- a/docs/narr/project.rst +++ b/docs/narr/project.rst @@ -976,10 +976,10 @@ named ``views`` instead of within a single ``views.py`` file, you might: *package*.) - *Move* the existing ``views.py`` file to a file inside the new ``views`` - directory named, say, ``blog.py``. The template :term:`asset + directory named, say, ``blog.py``. Because the ``templates`` directory + remains in the ``myproject`` package the template :term:`asset specification`s in ``blog.py`` must now be fully qualified with the - project's package name (``myproject:templates/blog.pt``) since the - ``templates`` directory remains in the ``myproject`` package. + project's package name (``myproject:templates/blog.pt``). You can then continue to add view callable functions to the ``blog.py`` module, but you can also add other ``.py`` files which contain view callable -- cgit v1.2.3 From 1a76ed41b133ea73c7d40997c6f564fd72d7273e Mon Sep 17 00:00:00 2001 From: Steve Piercy Date: Tue, 1 Oct 2013 00:48:53 -0700 Subject: Add comma --- docs/narr/project.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/narr/project.rst b/docs/narr/project.rst index e5da3b5c5..4c19982d6 100644 --- a/docs/narr/project.rst +++ b/docs/narr/project.rst @@ -144,7 +144,7 @@ contains no space characters, so it's wise to *avoid* a path that contains i.e. ``My Documents``. As a result, the author, when he uses Windows, just puts his projects in ``C:\projects``. -.. warning:: +.. warning:: You’ll need to avoid using ``pcreate`` to create a project with the same name as a Python standard library component. In particular, this means you @@ -977,7 +977,7 @@ named ``views`` instead of within a single ``views.py`` file, you might: - *Move* the existing ``views.py`` file to a file inside the new ``views`` directory named, say, ``blog.py``. Because the ``templates`` directory - remains in the ``myproject`` package the template :term:`asset + remains in the ``myproject`` package, the template :term:`asset specification`s in ``blog.py`` must now be fully qualified with the project's package name (``myproject:templates/blog.pt``). @@ -1028,7 +1028,7 @@ server. Waitress is a server that is suited for development and light production usage. It's not the fastest nor the most featureful WSGI server. Instead, its main feature is that it works on all platforms that Pyramid needs to run on, making it a good choice as a default server from the -perspective of Pyramid's developers. +perspective of Pyramid's developers. Any WSGI server is capable of running a :app:`Pyramid` application. But we suggest you stick with the default server for development, and that you wait -- cgit v1.2.3 From fd078969a105d421f9e07aad9a7a720e2f5f2900 Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Tue, 1 Oct 2013 10:53:41 -0400 Subject: remove unused files --- .../scaffolds/alchemy/+package+/static/pyramid-small.png | Bin 7044 -> 0 bytes .../scaffolds/starter/+package+/static/pyramid-small.png | Bin 7044 -> 0 bytes .../scaffolds/zodb/+package+/static/pyramid-small.png | Bin 7044 -> 0 bytes 3 files changed, 0 insertions(+), 0 deletions(-) delete mode 100644 pyramid/scaffolds/alchemy/+package+/static/pyramid-small.png delete mode 100644 pyramid/scaffolds/starter/+package+/static/pyramid-small.png delete mode 100644 pyramid/scaffolds/zodb/+package+/static/pyramid-small.png diff --git a/pyramid/scaffolds/alchemy/+package+/static/pyramid-small.png b/pyramid/scaffolds/alchemy/+package+/static/pyramid-small.png deleted file mode 100644 index a5bc0ade7..000000000 Binary files a/pyramid/scaffolds/alchemy/+package+/static/pyramid-small.png and /dev/null differ diff --git a/pyramid/scaffolds/starter/+package+/static/pyramid-small.png b/pyramid/scaffolds/starter/+package+/static/pyramid-small.png deleted file mode 100644 index a5bc0ade7..000000000 Binary files a/pyramid/scaffolds/starter/+package+/static/pyramid-small.png and /dev/null differ diff --git a/pyramid/scaffolds/zodb/+package+/static/pyramid-small.png b/pyramid/scaffolds/zodb/+package+/static/pyramid-small.png deleted file mode 100644 index a5bc0ade7..000000000 Binary files a/pyramid/scaffolds/zodb/+package+/static/pyramid-small.png and /dev/null differ -- cgit v1.2.3 From 073e5247f4adf68fe96423d6669b437dc6f337a8 Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Tue, 1 Oct 2013 21:43:36 -0400 Subject: - Fix the ``pcreate`` script so that when the target directory name ends with a slash it does not produce a non-working project directory structure. Previously saying ``pcreate -s starter /foo/bar/`` produced different output than saying ``pcreate -s starter /foo/bar``. The former did not work properly. --- CHANGES.txt | 9 +++++++++ pyramid/scripts/pcreate.py | 2 +- pyramid/tests/test_scripts/test_pcreate.py | 15 +++++++++++++++ 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/CHANGES.txt b/CHANGES.txt index 8b2210a99..34e722fd6 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,6 +1,15 @@ Unreleased ========== +Bug Fixes +--------- + +- Fix the ``pcreate`` script so that when the target directory name ends with a + slash it does not produce a non-working project directory structure. + Previously saying ``pcreate -s starter /foo/bar/`` produced different output + than saying ``pcreate -s starter /foo/bar``. The former did not work + properly. + Documentation ------------- diff --git a/pyramid/scripts/pcreate.py b/pyramid/scripts/pcreate.py index ba4eb0856..5e2240856 100644 --- a/pyramid/scripts/pcreate.py +++ b/pyramid/scripts/pcreate.py @@ -77,8 +77,8 @@ class PCreateCommand(object): def render_scaffolds(self): options = self.options args = self.args - project_name = os.path.basename(args[0]) output_dir = os.path.abspath(os.path.normpath(args[0])) + project_name = os.path.basename(os.path.split(output_dir)[1]) pkg_name = _bad_chars_re.sub('', project_name.lower()) safe_name = pkg_resources.safe_name(project_name) egg_name = pkg_resources.to_filename(safe_name) diff --git a/pyramid/tests/test_scripts/test_pcreate.py b/pyramid/tests/test_scripts/test_pcreate.py index 1406d3911..6516ac229 100644 --- a/pyramid/tests/test_scripts/test_pcreate.py +++ b/pyramid/tests/test_scripts/test_pcreate.py @@ -110,6 +110,21 @@ class TestPCreateCommand(unittest.TestCase): scaffold2.vars, {'project': 'Distro', 'egg': 'Distro', 'package': 'distro'}) + def test_known_scaffold_with_path_as_project_target_rendered(self): + import os + cmd = self._makeOne('-s', 'dummy', '/tmp/foo/Distro/') + scaffold = DummyScaffold('dummy') + cmd.scaffolds = [scaffold] + result = cmd.run() + self.assertEqual(result, 0) + self.assertEqual( + scaffold.output_dir, + os.path.normpath(os.path.join(os.getcwd(), '/tmp/foo/Distro')) + ) + self.assertEqual( + scaffold.vars, + {'project': 'Distro', 'egg': 'Distro', 'package': 'distro'}) + class Test_main(unittest.TestCase): def _callFUT(self, argv): from pyramid.scripts.pcreate import main -- cgit v1.2.3 From 678f49d2e08b128785e32ed6fc9e12df4713ad7c Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Tue, 1 Oct 2013 22:10:36 -0400 Subject: - Fix the ``principals_allowed_by_permission`` method of ``ACLAuthorizationPolicy`` so it anticipates a callable ``__acl__`` on resources. Previously it did not try to call the ``__acl__`` if it was callable. --- CHANGES.txt | 5 +++++ pyramid/authorization.py | 3 +++ pyramid/tests/test_authorization.py | 13 +++++++++++++ 3 files changed, 21 insertions(+) diff --git a/CHANGES.txt b/CHANGES.txt index 34e722fd6..880f7a3f3 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -10,6 +10,11 @@ Bug Fixes than saying ``pcreate -s starter /foo/bar``. The former did not work properly. +- Fix the ``principals_allowed_by_permission`` method of + ``ACLAuthorizationPolicy`` so it anticipates a callable ``__acl__`` + on resources. Previously it did not try to call the ``__acl__`` + if it was callable. + Documentation ------------- diff --git a/pyramid/authorization.py b/pyramid/authorization.py index 1fd05e244..5e7baa19d 100644 --- a/pyramid/authorization.py +++ b/pyramid/authorization.py @@ -122,6 +122,9 @@ class ACLAuthorizationPolicy(object): allowed_here = set() denied_here = set() + if acl and callable(acl): + acl = acl() + for ace_action, ace_principal, ace_permissions in acl: if not is_nonstr_iter(ace_permissions): ace_permissions = [ace_permissions] diff --git a/pyramid/tests/test_authorization.py b/pyramid/tests/test_authorization.py index 60b1b0c8d..05cd3b4f8 100644 --- a/pyramid/tests/test_authorization.py +++ b/pyramid/tests/test_authorization.py @@ -146,6 +146,19 @@ class TestACLAuthorizationPolicy(unittest.TestCase): policy.principals_allowed_by_permission(context, 'read')) self.assertEqual(result, ['chrism']) + def test_principals_allowed_by_permission_callable_acl(self): + from pyramid.security import Allow + from pyramid.security import DENY_ALL + context = DummyContext() + acl = lambda: [ (Allow, 'chrism', ('read', 'write')), + DENY_ALL, + (Allow, 'other', 'read') ] + context.__acl__ = acl + policy = self._makeOne() + result = sorted( + policy.principals_allowed_by_permission(context, 'read')) + self.assertEqual(result, ['chrism']) + def test_principals_allowed_by_permission_string_permission(self): from pyramid.security import Allow context = DummyContext() -- cgit v1.2.3 From f24ac4c471a458aec0cde232925c8fab652bafcc Mon Sep 17 00:00:00 2001 From: "Karl O. Pinc" Date: Wed, 2 Oct 2013 11:31:47 -0500 Subject: Docs: project.rst: Eliminate reduncency and better explain renderer. --- docs/narr/project.rst | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/docs/narr/project.rst b/docs/narr/project.rst index 602f15fef..09e07ee6d 100644 --- a/docs/narr/project.rst +++ b/docs/narr/project.rst @@ -871,18 +871,17 @@ specification` that specifies the ``mytemplate.pt`` file within the ``templates`` directory of the ``myproject`` package. The asset specification could have also been specified as ``myproject:templates/mytemplate.pt``; the leading package name and colon is -optional. The template file it actually points to is a :term:`Chameleon` ZPT -template file. +optional. The template file pointed to is a :term:`Chameleon` ZPT +template file (``templates/my_template.pt``). This view callable function is handed a single piece of information: the :term:`request`. The *request* is an instance of the :term:`WebOb` ``Request`` class representing the browser's request to our server. -This view returns a dictionary. When this view is invoked, a -:term:`renderer` converts the dictionary returned by the view into HTML, and -returns the result as the :term:`response`. This view is configured to -invoke a renderer which uses a :term:`Chameleon` ZPT template -(``templates/my_template.pt``). +This view is configured to invoke a :term;`renderer` on a template. The +dictionary the view returns (on line 6) provides the value the renderer +substitutes into the template when generating HTML. The renderer then +returns the HTML in a :term:`response`. See :ref:`views_which_use_a_renderer` for more information about how views, renderers, and templates relate and cooperate. -- cgit v1.2.3 From 77edee7e91356f4f0f1d12c2dd159965b0576109 Mon Sep 17 00:00:00 2001 From: "Karl O. Pinc" Date: Wed, 2 Oct 2013 11:33:50 -0500 Subject: Docs: project.rst: Emphasize key takeaway; use dicts to supply values to templates. --- docs/narr/project.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/narr/project.rst b/docs/narr/project.rst index 09e07ee6d..359fb31d3 100644 --- a/docs/narr/project.rst +++ b/docs/narr/project.rst @@ -878,6 +878,8 @@ This view callable function is handed a single piece of information: the :term:`request`. The *request* is an instance of the :term:`WebOb` ``Request`` class representing the browser's request to our server. +.. note:: Dictionaries (typically) provide values to :term:`template`s. + This view is configured to invoke a :term;`renderer` on a template. The dictionary the view returns (on line 6) provides the value the renderer substitutes into the template when generating HTML. The renderer then -- cgit v1.2.3 From 68d16988404aec339fde1df7822c783d3ea23af6 Mon Sep 17 00:00:00 2001 From: "Karl O. Pinc" Date: Wed, 2 Oct 2013 11:35:34 -0500 Subject: Docs: renderers.rst: Explain typical renderer usage. --- docs/narr/renderers.rst | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/docs/narr/renderers.rst b/docs/narr/renderers.rst index 3059aef35..235dbaf83 100644 --- a/docs/narr/renderers.rst +++ b/docs/narr/renderers.rst @@ -49,10 +49,14 @@ Writing View Callables Which Use a Renderer ------------------------------------------- As we've seen, a view callable needn't always return a Response object. -Instead, it may return an arbitrary Python object, with the expectation -that a :term:`renderer` will convert that object into a response instance on -your behalf. Some renderers use a templating system; other renderers use -object serialization techniques. +Instead, it may return an arbitrary Python object, with the expectation that +a :term:`renderer` will convert that object into a response instance on your +behalf. Some renderers use a templating system; other renderers use object +serialization techniques. Because renderers inject variable data into some +output (otherwise a static Response object could be returned) the renderer +must have some means of identifying the data and mapping its transformation +into the desired output. Often, as the means of providing this mapping, the +object supplied to the renderer is a Python dictionary. View configuration can vary the renderer associated with a view callable via the ``renderer`` attribute. For example, this call to -- cgit v1.2.3 From 190b5644c473286f8066c9eb430c567dfdeb4913 Mon Sep 17 00:00:00 2001 From: "Karl O. Pinc" Date: Wed, 2 Oct 2013 13:36:05 -0500 Subject: Docs: sessions.rst: Explain example. --- docs/narr/sessions.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/narr/sessions.rst b/docs/narr/sessions.rst index 358977089..eafa9dbf9 100644 --- a/docs/narr/sessions.rst +++ b/docs/narr/sessions.rst @@ -99,6 +99,10 @@ example: else: return Response('Fred was not in the session') +The first time this view is invoked produces ``Fred was not in the +session``. Subsequent invocations produce ``Fred was in the +session``. + You can use a session much like a Python dictionary. It supports all dictionary methods, along with some extra attributes, and methods. -- cgit v1.2.3 From 66be39bf656a2840931603bc959e38ff95e53164 Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Wed, 2 Oct 2013 15:35:24 -0400 Subject: - Removed mention of ``pyramid_beaker`` from docs. Beaker is no longer maintained. Point people at ``pyramid_redis_sessions`` instead. --- CHANGES.txt | 3 +++ docs/conf.py | 3 --- docs/narr/sessions.rst | 15 ++------------- 3 files changed, 5 insertions(+), 16 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 880f7a3f3..cb28d880b 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -20,6 +20,9 @@ Documentation - Added a "Quick Tutorial" to go with the Quick Tour +- Removed mention of ``pyramid_beaker`` from docs. Beaker is no longer + maintained. Point people at ``pyramid_redis_sessions`` instead. + 1.5a2 (2013-09-22) ================== diff --git a/docs/conf.py b/docs/conf.py index ee852aa51..3b6e75a17 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -73,9 +73,6 @@ intersphinx_mapping = { 'http://docs.pylonsproject.org/projects/deform/en/latest', None), 'sqla': ('http://docs.sqlalchemy.org/en/latest', None), - 'beaker': ( - 'http://docs.pylonsproject.org/projects/pyramid_beaker/en/latest', - None), 'who': ('http://docs.repoze.org/who/latest', None), 'python': ('http://docs.python.org', None), 'python3': ('http://docs.python.org/3', None), diff --git a/docs/narr/sessions.rst b/docs/narr/sessions.rst index 358977089..f8279b0a5 100644 --- a/docs/narr/sessions.rst +++ b/docs/narr/sessions.rst @@ -146,8 +146,6 @@ Some gotchas: you've changed sessioning data. .. index:: - single: pyramid_beaker - single: Beaker single: pyramid_redis_sessions single: session factory (alternates) @@ -156,20 +154,11 @@ Some gotchas: Using Alternate Session Factories --------------------------------- -At the time of this writing, exactly two alternate session factories -exist. - -The first is named ``pyramid_redis_sessions``. It can be downloaded from PyPI. +At the time of this writing, exactly one project-endorsed alternate session +factory exists named``pyramid_redis_sessions``. It can be downloaded from PyPI. It uses Redis as a backend. It is the recommended persistent session solution at the time of this writing. -The second is named ``pyramid_beaker``. This is a session factory that uses the -`Beaker `_ library as a backend. Beaker has -support for file-based sessions, database based sessions, and encrypted -cookie-based sessions. See `the pyramid_beaker documentation -`_ for more -information about ``pyramid_beaker``. - .. index:: single: session factory (custom) -- cgit v1.2.3 From b31cdc5beb173716235a026d264dafde12fea109 Mon Sep 17 00:00:00 2001 From: "Karl O. Pinc" Date: Wed, 2 Oct 2013 14:47:01 -0500 Subject: Docs: sessions.rst: Sessions only work when the client cooperates. --- docs/narr/sessions.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/narr/sessions.rst b/docs/narr/sessions.rst index eafa9dbf9..db1e0ea20 100644 --- a/docs/narr/sessions.rst +++ b/docs/narr/sessions.rst @@ -101,7 +101,8 @@ example: The first time this view is invoked produces ``Fred was not in the session``. Subsequent invocations produce ``Fred was in the -session``. +session``, assuming of course that the client side maintains the +session's identity across multiple requests. You can use a session much like a Python dictionary. It supports all dictionary methods, along with some extra attributes, and methods. -- cgit v1.2.3 From 5bf27497638ad607f0e42feb10145cd6720b74d3 Mon Sep 17 00:00:00 2001 From: "Karl O. Pinc" Date: Wed, 2 Oct 2013 15:20:59 -0500 Subject: Docs: Make statements more concreate regards renderers getting data from dictionaries. --- docs/narr/project.rst | 2 +- docs/narr/renderers.rst | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/docs/narr/project.rst b/docs/narr/project.rst index 9a1ba190d..61b6ae316 100644 --- a/docs/narr/project.rst +++ b/docs/narr/project.rst @@ -878,7 +878,7 @@ This view callable function is handed a single piece of information: the :term:`request`. The *request* is an instance of the :term:`WebOb` ``Request`` class representing the browser's request to our server. -.. note:: Dictionaries (typically) provide values to :term:`template`s. +.. note:: Dictionaries provide values to :term:`template`s. This view is configured to invoke a :term;`renderer` on a template. The dictionary the view returns (on line 6) provides the value the renderer diff --git a/docs/narr/renderers.rst b/docs/narr/renderers.rst index 235dbaf83..4046c67fa 100644 --- a/docs/narr/renderers.rst +++ b/docs/narr/renderers.rst @@ -52,11 +52,9 @@ As we've seen, a view callable needn't always return a Response object. Instead, it may return an arbitrary Python object, with the expectation that a :term:`renderer` will convert that object into a response instance on your behalf. Some renderers use a templating system; other renderers use object -serialization techniques. Because renderers inject variable data into some -output (otherwise a static Response object could be returned) the renderer -must have some means of identifying the data and mapping its transformation -into the desired output. Often, as the means of providing this mapping, the -object supplied to the renderer is a Python dictionary. +serialization techniques. In practice, renderers obtain application data +values from Python dictionaries so, in practice, view callables which use +renderers return Python dictionaries. View configuration can vary the renderer associated with a view callable via the ``renderer`` attribute. For example, this call to -- cgit v1.2.3 From 47e13e042c270f9ffb3ac86b294e89ec4b1fef6a Mon Sep 17 00:00:00 2001 From: "Karl O. Pinc" Date: Wed, 2 Oct 2013 15:27:32 -0500 Subject: Docs: project.rst: Fix markup failure just introduced. --- docs/narr/project.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/narr/project.rst b/docs/narr/project.rst index 61b6ae316..2acc81e17 100644 --- a/docs/narr/project.rst +++ b/docs/narr/project.rst @@ -880,7 +880,7 @@ This view callable function is handed a single piece of information: the .. note:: Dictionaries provide values to :term:`template`s. -This view is configured to invoke a :term;`renderer` on a template. The +This view is configured to invoke a :term:`renderer` on a template. The dictionary the view returns (on line 6) provides the value the renderer substitutes into the template when generating HTML. The renderer then returns the HTML in a :term:`response`. -- cgit v1.2.3 From 15afe5e7fb5dafa570faf055eb4b4a4518349409 Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Wed, 2 Oct 2013 16:38:28 -0400 Subject: render the qs such that when provided with None as a value, it will render the key plus the equal sign --- pyramid/encode.py | 2 +- pyramid/tests/test_encode.py | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/pyramid/encode.py b/pyramid/encode.py index 9341f7665..9e190bc21 100644 --- a/pyramid/encode.py +++ b/pyramid/encode.py @@ -55,7 +55,7 @@ def urlencode(query, doseq=True): result += '%s%s=%s' % (prefix, k, x) prefix = '&' elif v is None: - result += '%s%s' % (prefix, k) + result += '%s%s=' % (prefix, k) else: v = _enc(v) result += '%s%s=%s' % (prefix, k, v) diff --git a/pyramid/tests/test_encode.py b/pyramid/tests/test_encode.py index 1e0ecbe20..908249877 100644 --- a/pyramid/tests/test_encode.py +++ b/pyramid/tests/test_encode.py @@ -43,11 +43,15 @@ class UrlEncodeTests(unittest.TestCase): def test_None_value(self): result = self._callFUT([('a', None)]) - self.assertEqual(result, 'a') + self.assertEqual(result, 'a=') def test_None_value_with_prefix(self): result = self._callFUT([('a', '1'), ('b', None)]) - self.assertEqual(result, 'a=1&b') + self.assertEqual(result, 'a=1&b=') + + def test_None_value_with_prefix_values(self): + result = self._callFUT([('a', '1'), ('b', None), ('c', None)]) + self.assertEqual(result, 'a=1&b=&c=') class URLQuoteTests(unittest.TestCase): def _callFUT(self, val, safe=''): -- cgit v1.2.3 From 4122733091d0204b22d7acedfdf985caed17f93f Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Wed, 2 Oct 2013 17:29:39 -0400 Subject: get rid of note that appears to be explained in the next para --- docs/narr/project.rst | 2 -- 1 file changed, 2 deletions(-) diff --git a/docs/narr/project.rst b/docs/narr/project.rst index 2acc81e17..bfd00d3a0 100644 --- a/docs/narr/project.rst +++ b/docs/narr/project.rst @@ -878,8 +878,6 @@ This view callable function is handed a single piece of information: the :term:`request`. The *request* is an instance of the :term:`WebOb` ``Request`` class representing the browser's request to our server. -.. note:: Dictionaries provide values to :term:`template`s. - This view is configured to invoke a :term:`renderer` on a template. The dictionary the view returns (on line 6) provides the value the renderer substitutes into the template when generating HTML. The renderer then -- cgit v1.2.3 From ab2fedf7adaec0a56a69beed35312c88d7961c6c Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Wed, 2 Oct 2013 17:47:17 -0400 Subject: fix the docs build and get rid of stray references to Beaker --- docs/glossary.rst | 9 ++++++++- docs/narr/project.rst | 2 +- docs/narr/sessions.rst | 8 ++++---- docs/quick_tour.rst | 7 +++---- 4 files changed, 16 insertions(+), 10 deletions(-) diff --git a/docs/glossary.rst b/docs/glossary.rst index 7dc69c7c4..398f945a4 100644 --- a/docs/glossary.rst +++ b/docs/glossary.rst @@ -1009,7 +1009,8 @@ Glossary Green Unicorn Aka ``gunicorn``, a fast :term:`WSGI` server that runs on UNIX under - Python 2.6+ or Python 3.1+. 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 @@ -1021,3 +1022,9 @@ Glossary A Python :term:`distribution` that uses Pyramid's extensibility to plug into a Pyramid application and provide extra, configurable services. + + pyramid_redis_sessions + A package by Eric Rasmussen which allows you to store Pyramid session + data in a Redis database. See + https://pypi.python.org/pypi/pyramid_redis_sessions for more information. + diff --git a/docs/narr/project.rst b/docs/narr/project.rst index bfd00d3a0..9451f41b1 100644 --- a/docs/narr/project.rst +++ b/docs/narr/project.rst @@ -977,7 +977,7 @@ named ``views`` instead of within a single ``views.py`` file, you might: - *Move* the existing ``views.py`` file to a file inside the new ``views`` directory named, say, ``blog.py``. Because the ``templates`` directory remains in the ``myproject`` package, the template :term:`asset - specification`s in ``blog.py`` must now be fully qualified with the + specification` values in ``blog.py`` must now be fully qualified with the project's package name (``myproject:templates/blog.pt``). You can then continue to add view callable functions to the ``blog.py`` diff --git a/docs/narr/sessions.rst b/docs/narr/sessions.rst index f4da5d82a..649d22bd2 100644 --- a/docs/narr/sessions.rst +++ b/docs/narr/sessions.rst @@ -159,10 +159,10 @@ Some gotchas: Using Alternate Session Factories --------------------------------- -At the time of this writing, exactly one project-endorsed alternate session -factory exists named``pyramid_redis_sessions``. It can be downloaded from PyPI. -It uses Redis as a backend. It is the recommended persistent session solution -at the time of this writing. +At the time of this writing, exactly one project-endorsed alternate session +factory exists named :term:`pyramid_redis_sessions`. It can be downloaded from +PyPI. It uses the Redis database as a backend. It is the recommended +persistent session solution at the time of this writing. .. index:: single: session factory (custom) diff --git a/docs/quick_tour.rst b/docs/quick_tour.rst index 98584e608..2db18c8a7 100644 --- a/docs/quick_tour.rst +++ b/docs/quick_tour.rst @@ -729,8 +729,8 @@ that requires semi-permanent data to be saved. For example, a shopping cart. This is called a :term:`session`. Pyramid has basic built-in support for sessions, with add-ons such as -*Beaker* (or your own custom sessioning engine) that provide richer -session support. Let's take a look at the +``pyramid_redis_sessions`` (or your own custom sessioning engine) that provide +richer session support. Let's take a look at the :doc:`built-in sessioning support <../narr/sessions>`. In our ``__init__.py`` we first import the kind of sessioning we want: @@ -768,8 +768,7 @@ Jinja2 template: .. seealso:: See Also: :ref:`Quick Tutorial Sessions `, :ref:`sessions_chapter`, :ref:`flash_messages`, - :ref:`session_module`, and - :ref:`Beaker sessioning middleware ` + :ref:`session_module`, and :term:`pyramid_redis_sessions`. Databases ========= -- cgit v1.2.3 From 79d9d6862ff906aa0bf26968e0ba763c54775b5c Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Wed, 2 Oct 2013 18:12:29 -0400 Subject: correct the explanation of the behavior change --- CHANGES.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGES.txt b/CHANGES.txt index c8b79d65f..051328a02 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -36,7 +36,7 @@ Backwards Incompatibilities ``query`` parameter of ``request.resource_url`` (and their variants), used to encode a value of ``None`` as the string ``'None'``, leaving the resulting query string to be ``a=b&key=None``. The value is now dropped in this - situation, leaving a query string of ``a=b&key``. + situation, leaving a query string of ``a=b&key=``. See https://github.com/Pylons/pyramid/issues/1119 1.5a2 (2013-09-22) -- cgit v1.2.3 From 96188ac4b74cb1e67cb95afdb9519ecd8934d688 Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Wed, 2 Oct 2013 18:56:56 -0400 Subject: rearrange the fix --- docs/glossary.rst | 23 ++++++++++++++--------- docs/narr/traversal.rst | 14 +++++--------- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/docs/glossary.rst b/docs/glossary.rst index 398f945a4..406b81778 100644 --- a/docs/glossary.rst +++ b/docs/glossary.rst @@ -505,15 +505,20 @@ Glossary available as its ``__parent__`` attribute. root factory - The "root factory" of a :app:`Pyramid` application is called - on every request sent to the application. The root factory - returns the traversal root of an application. It is - conventionally named ``get_root``. An application may supply a - root factory to :app:`Pyramid` during the construction of a - :term:`Configurator`. If a root factory is not supplied, the - application uses a default root object. Use of the default root - object is useful in application which use :term:`URL dispatch` for - all URL-to-view code mappings. + The "root factory" of a :app:`Pyramid` application is called on every + request sent to the application. The root factory returns the traversal + root of an application. It is conventionally named ``get_root``. An + application may supply a root factory to :app:`Pyramid` during the + construction of a :term:`Configurator`. If a root factory is not + supplied, the application creates a default root object using the + :term:`default root factory`. + + default root factory + If an application does not register a :term:`root factory` at Pyramid + configuration time, a *default* root factory is used to created the + default root object. Use of the default root object is useful in + application which use :term:`URL dispatch` for all URL-to-view code + mappings, and does not (knowingly) use traversal otherwise. SQLAlchemy `SQLAlchemy `_ is an object diff --git a/docs/narr/traversal.rst b/docs/narr/traversal.rst index fb4adff61..454bb5620 100644 --- a/docs/narr/traversal.rst +++ b/docs/narr/traversal.rst @@ -128,12 +128,6 @@ Here's an example of a simple root factory class: def __init__(self, request): pass -..note:: - For the purpose of understanding traversal, and the contents within - this document, the above Root is an analogue to the default root - factory present in Pyramid. The default root factory is very simple and - not very useful unless using :term:`URL dispatch`. - Here's an example of using this root factory within startup configuration, by passing it to an instance of a :term:`Configurator` named ``config``: @@ -152,13 +146,15 @@ refer to a root factory defined in a different module. If no :term:`root factory` is passed to the :app:`Pyramid` :term:`Configurator` constructor, or if the ``root_factory`` value -specified is ``None``, a *default* root factory is used. The default +specified is ``None``, a :term:`default root factory` is used. The default root factory always returns a resource that has no child resources; it is effectively empty. Usually a root factory for a traversal-based application will be more -complicated than the above ``Root`` class; in particular it may be -associated with a database connection or another persistence mechanism. +complicated than the above ``Root`` class; in particular it may be associated +with a database connection or another persistence mechanism. The above +``Root`` class is analogous to the default root factory present in Pyramid. The +default root factory is very simple and not very useful. .. note:: -- cgit v1.2.3 From 9951556030aeed07978472f59b7843273bcb84a8 Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Fri, 4 Oct 2013 21:53:46 -0400 Subject: normalize tox-vs-byhand, add note about --no-site-packages, tell folks to use 'setup.py docs' and not 'setup.py dev docs' based on report from karlping --- HACKING.txt | 121 ++++++++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 80 insertions(+), 41 deletions(-) diff --git a/HACKING.txt b/HACKING.txt index 4ebb59160..be67000ce 100644 --- a/HACKING.txt +++ b/HACKING.txt @@ -6,47 +6,43 @@ Here are some guidelines about hacking on Pyramid. Using a Development Checkout ---------------------------- -Below is a quick start on creating a development environment using a Pyramid -checkout. +You'll have to create a development environment to hack on Pyramid, using a +Pyramid checkout. You can either do this by hand or, if you have ``tox`` +installed (it's on PyPI), you can (ab)use tox to get a working development +environment. Each installation method is described below. -- Create a new directory somewhere and ``cd`` to it:: - - $ mkdir ~/hack-on-pyramid - $ cd ~/hack-on-pyramid - -- Check out a read-only copy of the Pyramid source:: +By Hand ++++++++ - $ git clone git://github.com/Pylons/pyramid.git . +- Check out Pyramid from source:: - (alternately, create a writeable fork on GitHub and check that out). - -Since pyramid is a framework and not an application, it can be -convenient to work against a sample application, preferably in its own -virtualenv. A quick way to achieve this is to (ab-)use ``tox`` -(http://tox.readthedocs.org/en/latest/) with a custom configuration -file that's part of the checkout:: - - tox -c hacking-tox.ini + $ cd ~ + $ git clone git://github.com/Pylons/pyramid.git hack-on-pyramid + $ cd hack-on-pyramid -This will create a python-2.7 based virtualenv named ``env27`` (pyramid's -``.gitconfig` ignores all top-level folders that start with ``env`` specifically -for this use case) and inside that a simple pyramid application named -``hacking`` that you can then fire up like so:: +- Create a virtualenv in which to install Pyramid:: - cd env27/hacking - ../bin/pserve development.ini + $ cd ~/hack-on-pyramid + $ virtualenv -ppython2.7 env -Alternatively, if you don't want to install ``tox`` at this point, -you an achieve the same manually by following these steps: + Note that very old versions of virtualenv (virtualenv versions below, say, + 1.10 or thereabouts) require you to pass a ``--no-site-packages`` flag to + get a completely isolated environment. If you're on an old system, use + ``virtualenv --no-site-packages`` instead of ``virtualenv`` above. -- Create a virtualenv in which to install Pyramid:: + You can choose which Python version you want to use by passing a ``-p`` + flag to ``virtualenv``. For example, ``virtualenv -ppython2.7`` + chooses the Python 2.7 interpreter to be installed. - $ virtualenv env + From here on in within these instructions, the ``~/hack-on-pyramid/env`` + virtual environment you created above will be referred to as ``$VENV``. + To use the instructions in the steps that follow literally, use the + ``export VENV=~/hack-on-pyramid/env`` command. - Install ``setuptools-git`` into the virtualenv (for good measure, as we're using git to do version control):: - $ $VENV/bin/easy_install setuptools-git + $ $VENV/bin/easy_install setuptools-git - Install Pyramid from the checkout into the virtualenv using ``setup.py dev``. ``setup.py dev`` is an alias for "setup.py develop" which also @@ -54,21 +50,54 @@ you an achieve the same manually by following these steps: ``setup.py dev`` *must* be done while the current working directory is the ``pyramid`` checkout directory:: - $ cd pyramid - $ $VENV/bin/python setup.py dev + $ cd ~/hack-on-pyramid + $ $VENV/bin/python setup.py dev - At that point, you should be able to create new Pyramid projects by using ``pcreate``:: - $ cd ../env - $ $VENV/bin/pcreate -s starter starter + $ cd $VENV + $ bin/pcreate -s starter starter - And install those projects (also using ``setup.py develop``) into the virtualenv:: - $ cd starter + $ cd $VENV/starter $ $VENV/bin/python setup.py develop +Using Tox ++++++++++ + +Alternatively, if you already have ``tox`` installed, there is an easier +way to get going. + +- Create a new directory somewhere and ``cd`` to it:: + + $ mkdir ~/hack-on-pyramid + $ cd ~/hack-on-pyramid + +- Check out a read-only copy of the Pyramid source:: + + $ git clone git://github.com/Pylons/pyramid.git . + + (alternately, create a writeable fork on GitHub and check that out). + +Since pyramid is a framework and not an application, it can be +convenient to work against a sample application, preferably in its own +virtualenv. A quick way to achieve this is to (ab-)use ``tox`` +(http://tox.readthedocs.org/en/latest/) with a custom configuration +file that's part of the checkout:: + + tox -c hacking-tox.ini + +This will create a python-2.7 based virtualenv named ``env27`` (pyramid's +``.gitconfig` ignores all top-level folders that start with ``env`` specifically +for this use case) and inside that a simple pyramid application named +``hacking`` that you can then fire up like so:: + + cd env27/hacking + ../bin/pserve development.ini + Adding Features --------------- @@ -133,7 +162,7 @@ Running Tests it creates a virtualenv for each version/platform combination. For example:: - $ /usr/bin/easy_install tox + $ sudo /usr/bin/easy_install tox $ cd ~/hack-on-pyramid/ $ /usr/bin/tox @@ -163,18 +192,28 @@ or adds the feature. To build and review docs (where ``$VENV`` refers to the virtualenv you're using to develop Pyramid): -1. Run ``$VENV/bin/python setup.py dev docs``. This will cause Sphinx - and all development requirements to be installed in your virtualenv. +1. After follwing the steps above in "Using a Development Checkout", cause + Sphinx and all development requirements to be installed in your + virtualenv:: + + $ cd ~/hack-on-pyramid + $ $VENV/bin/python setup.py docs 2. Update all git submodules from the top-level of your Pyramid checkout, like - so: - git submodule update --init --recursive + so:: + + $ git submodule update --init --recursive + This will checkout theme subrepositories and prevent error conditions when HTML docs are generated. 3. cd to the ``docs`` directory within your Pyramid checkout and execute - ``make clean html SPHINXBUILD=$VENV/bin/sphinx-build``. The - ``SPHINXBUILD=...`` hair is there in order to tell it to use the + the ``make`` command with some flags:: + + $ cd ~/hack-on-pyramid/pyramid/docs + $ make clean html SPHINXBUILD=$VENV/bin/sphinx-build + + The ``SPHINXBUILD=...`` hair is there in order to tell it to use the virtualenv Python, which will have both Sphinx and Pyramid (for API documentation generation) installed. -- cgit v1.2.3 From 1f7a00346411033d935bf931c206b585353f8be4 Mon Sep 17 00:00:00 2001 From: "Karl O. Pinc" Date: Sat, 5 Oct 2013 00:37:09 -0500 Subject: Docs: Link from renderer narrative docs to example render_to_response call, and index the example. More fully explain the 2 examples, one with render_to_response call and one without. --- docs/narr/introduction.rst | 11 +++++++++-- docs/narr/renderers.rst | 10 ++++++---- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/docs/narr/introduction.rst b/docs/narr/introduction.rst index 032f4be6b..8c2acf95c 100644 --- a/docs/narr/introduction.rst +++ b/docs/narr/introduction.rst @@ -321,7 +321,14 @@ assertion instead that the view returns "the right stuff" in the dictionary it returns. You can write "real" unit tests instead of functionally testing all of your views. -For example, instead of: +.. index:: + pair: renderer; explicitly calling + pair: view renderer; explictly calling + +.. _example_render_to_response_call: + +For example, instead of returning a ``Response`` object from a +``render_to_response`` call: .. code-block:: python :linenos: @@ -332,7 +339,7 @@ For example, instead of: return render_to_response('myapp:templates/mytemplate.pt', {'a':1}, request=request) -You can do this: +You can return a Python dictionary: .. code-block:: python :linenos: diff --git a/docs/narr/renderers.rst b/docs/narr/renderers.rst index 4046c67fa..b86f7298b 100644 --- a/docs/narr/renderers.rst +++ b/docs/narr/renderers.rst @@ -56,10 +56,12 @@ serialization techniques. In practice, renderers obtain application data values from Python dictionaries so, in practice, view callables which use renderers return Python dictionaries. -View configuration can vary the renderer associated with a view callable via -the ``renderer`` attribute. For example, this call to -:meth:`~pyramid.config.Configurator.add_view` associates the ``json`` renderer -with a view callable: +View callables can :ref:`explicitly call +` renderers but, typically, view +configuration declares the renderer used to render a view callable's +results. This is done with the ``renderer`` attribute. For example, +this call to :meth:`~pyramid.config.Configurator.add_view` associates +the ``json`` renderer with a view callable: .. code-block:: python -- cgit v1.2.3 From cabaa67149f95796aac35a19313ca543064a7a0b Mon Sep 17 00:00:00 2001 From: "Karl O. Pinc" Date: Sat, 5 Oct 2013 00:56:39 -0500 Subject: Docs: project.rst: Hilight that dictionaries provide values to templates. --- docs/narr/project.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/narr/project.rst b/docs/narr/project.rst index 9451f41b1..8788977c7 100644 --- a/docs/narr/project.rst +++ b/docs/narr/project.rst @@ -878,6 +878,8 @@ This view callable function is handed a single piece of information: the :term:`request`. The *request* is an instance of the :term:`WebOb` ``Request`` class representing the browser's request to our server. +.. note:: Dictionaries provide values to :term:`template`\s. + This view is configured to invoke a :term:`renderer` on a template. The dictionary the view returns (on line 6) provides the value the renderer substitutes into the template when generating HTML. The renderer then -- cgit v1.2.3 From a8cb84e04a81bcfd0236c3ff534919bb555e7ed3 Mon Sep 17 00:00:00 2001 From: BauhausSP Date: Sun, 6 Oct 2013 21:08:14 +0100 Subject: Fixed an example "from pyramid.view import view_config" instead of "from pyramid.view. import view_config" --- docs/narr/upgrading.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/narr/upgrading.rst b/docs/narr/upgrading.rst index ca6dc565b..64343ca3e 100644 --- a/docs/narr/upgrading.rst +++ b/docs/narr/upgrading.rst @@ -150,7 +150,7 @@ do things the newer way: .. code-block:: python :linenos: - from pyramid.view. import view_config + from pyramid.view import view_config from pyramid.static import static_view myview = static_view('static', 'static', use_subpath=True) -- cgit v1.2.3 From 0f5e17a983ecb97bb0bdeb169ac775886c9e15fe Mon Sep 17 00:00:00 2001 From: "Karl O. Pinc" Date: Mon, 7 Oct 2013 09:53:06 -0500 Subject: Docs: project.rst: Utilize sidebars for out-of-band text. --- docs/narr/project.rst | 58 ++++++++++++++++++++++++++++++--------------------- 1 file changed, 34 insertions(+), 24 deletions(-) diff --git a/docs/narr/project.rst b/docs/narr/project.rst index 8788977c7..622f40d69 100644 --- a/docs/narr/project.rst +++ b/docs/narr/project.rst @@ -210,6 +210,12 @@ Python interpreter from the :term:`virtualenv` you created during :ref:`installing_chapter` (the ``python`` command that lives in the ``bin`` directory of your virtualenv). +.. sidebar:: Verbose Testing + + The ``-q`` option is passed to the ``setup.py test`` command to limit the + output to a stream of dots. If you don't pass ``-q``, you'll see more + verbose test result output (which normally isn't very useful). + On UNIX: .. code-block:: text @@ -243,12 +249,6 @@ Here's sample output from a test run on UNIX: OK -.. note:: - - The ``-q`` option is passed to the ``setup.py test`` command to limit the - output to a stream of dots. If you don't pass ``-q``, you'll see more - verbose test result output (which normally isn't very useful). - The tests themselves are found in the ``tests.py`` module in your ``pcreate`` generated project. Within a project generated by the ``starter`` scaffold, a single sample test exists. @@ -684,6 +684,14 @@ use a different version control system, you may need to install a setuptools add-on such as ``setuptools-git`` or ``setuptools-hg`` for this behavior to work properly. +.. sidebar:: Python's ``setup.py`` + + ``setup.py`` is the de facto standard which Python developers use to + distribute their reusable code. You can read more about ``setup.py`` files + and their usage in the `Setuptools documentation + `_ and `The + Hitchhiker's Guide to Packaging `_. + .. index:: single: setup.py @@ -694,14 +702,6 @@ The ``setup.py`` file is a :term:`setuptools` setup file. It is meant to be run directly from the command line to perform a variety of functions, such as testing, packaging, and distributing your application. -.. note:: - - ``setup.py`` is the de facto standard which Python developers use to - distribute their reusable code. You can read more about ``setup.py`` files - and their usage in the `Setuptools documentation - `_ and `The - Hitchhiker's Guide to Packaging `_. - Our generated ``setup.py`` looks like this: .. literalinclude:: MyProject/setup.py @@ -857,6 +857,26 @@ and which returns a :term:`response`. :language: python :linenos: +.. sidebar:: Fully Interactive Development + + Because our ``development.ini`` has a ``pyramid.reload_templates = + true`` directive indicating that templates should be reloaded when + they change, you won't need to restart the application server to + see changes you make to templates. During development, this is + handy. If this directive had been ``false`` (or if the directive + did not exist), you would need to restart the application server + for each template change. For production applications, you should + set your project's ``pyramid.reload_templates`` to ``false`` to + increase template rendering speed. + + Pyramid can also dynamically reload changed Python files. For more + on this see :ref:`reloading_code` above. + + The :ref:`debug_toolbar` provides interactive access to your + application's internals and, should an exception occur, allows + interactive access to traceback execution stack frames from the + Python interpreter. + 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``). @@ -888,16 +908,6 @@ returns the HTML in a :term:`response`. See :ref:`views_which_use_a_renderer` for more information about how views, renderers, and templates relate and cooperate. -.. note:: Because our ``development.ini`` has a ``pyramid.reload_templates = - true`` directive indicating that templates should be reloaded when - they change, you won't need to restart the application server to - see changes you make to templates. During development, this is - handy. If this directive had been ``false`` (or if the directive - did not exist), you would need to restart the application server - for each template change. For production applications, you should - set your project's ``pyramid.reload_templates`` to ``false`` to increase - the speed at which templates may be rendered. - .. index:: single: static directory -- cgit v1.2.3 From 5276ce567b1c04e3d4cadcfb7f41b135296b1d39 Mon Sep 17 00:00:00 2001 From: "Karl O. Pinc" Date: Mon, 7 Oct 2013 09:55:07 -0500 Subject: Docs: project.rst: Move note that tempates get values from dictionaries down a paragraph. --- docs/narr/project.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/narr/project.rst b/docs/narr/project.rst index 622f40d69..fc1d473ac 100644 --- a/docs/narr/project.rst +++ b/docs/narr/project.rst @@ -898,13 +898,13 @@ This view callable function is handed a single piece of information: the :term:`request`. The *request* is an instance of the :term:`WebOb` ``Request`` class representing the browser's request to our server. -.. note:: Dictionaries provide values to :term:`template`\s. - This view is configured to invoke a :term:`renderer` on a template. The dictionary the view returns (on line 6) provides the value the renderer substitutes into the template when generating HTML. The renderer then returns the HTML in a :term:`response`. +.. note:: Dictionaries provide values to :term:`template`\s. + See :ref:`views_which_use_a_renderer` for more information about how views, renderers, and templates relate and cooperate. -- cgit v1.2.3 From daefb5f5009166ac9fbc3ba7fb6498d093620eec Mon Sep 17 00:00:00 2001 From: "Karl O. Pinc" Date: Mon, 7 Oct 2013 10:12:14 -0500 Subject: Doc: introduction.rst: Broaden debug toolbar feature description to include other interactive development features. --- docs/narr/introduction.rst | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/docs/narr/introduction.rst b/docs/narr/introduction.rst index 032f4be6b..64cce407a 100644 --- a/docs/narr/introduction.rst +++ b/docs/narr/introduction.rst @@ -176,8 +176,13 @@ static file server in production without changing any code. Example: :ref:`static_assets_section`. -Debug Toolbar -~~~~~~~~~~~~~ +Fully Interactive Development +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +When developing a Pyramid application a variety of interactive features are +available. Pyramid will automatically utilize changed templates when +rendering pages and automatically restart the application to incorporate +changed python code. Pyramid's debug toolbar comes activated when you use a Pyramid scaffold to render a project. This toolbar overlays your application in the browser, and -- cgit v1.2.3 From 6461f60320106b5114bb7f226959c7d7f2995ec2 Mon Sep 17 00:00:00 2001 From: "Karl O. Pinc" Date: Mon, 7 Oct 2013 11:26:22 -0500 Subject: Docs: introduction.rst: Improve wording. --- docs/narr/introduction.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/narr/introduction.rst b/docs/narr/introduction.rst index 64cce407a..816199038 100644 --- a/docs/narr/introduction.rst +++ b/docs/narr/introduction.rst @@ -179,10 +179,10 @@ Example: :ref:`static_assets_section`. Fully Interactive Development ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -When developing a Pyramid application a variety of interactive features are -available. Pyramid will automatically utilize changed templates when -rendering pages and automatically restart the application to incorporate -changed python code. +When developing a Pyramid application a variety of interactive +features are available. Pyramid can automatically utilize changed +templates when rendering pages and automatically restart the +application to incorporate changed python code. Pyramid's debug toolbar comes activated when you use a Pyramid scaffold to render a project. This toolbar overlays your application in the browser, and -- cgit v1.2.3 From 70b05dfaea547fea328a7054acd921f02be34a87 Mon Sep 17 00:00:00 2001 From: "Karl O. Pinc" Date: Mon, 7 Oct 2013 16:06:15 -0500 Subject: Docs: renders.rst: Use punctuation to make sentence simpler. --- docs/narr/renderers.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/narr/renderers.rst b/docs/narr/renderers.rst index b86f7298b..49f834ecb 100644 --- a/docs/narr/renderers.rst +++ b/docs/narr/renderers.rst @@ -57,7 +57,7 @@ values from Python dictionaries so, in practice, view callables which use renderers return Python dictionaries. View callables can :ref:`explicitly call -` renderers but, typically, view +` renderers; but typically view configuration declares the renderer used to render a view callable's results. This is done with the ``renderer`` attribute. For example, this call to :meth:`~pyramid.config.Configurator.add_view` associates -- cgit v1.2.3 From 77497acef17d5e5996ac231bf8ac9b679b291316 Mon Sep 17 00:00:00 2001 From: "Karl O. Pinc" Date: Mon, 7 Oct 2013 16:10:18 -0500 Subject: Docs: renders.rst: Break sentence into two to simplify. --- docs/narr/renderers.rst | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/docs/narr/renderers.rst b/docs/narr/renderers.rst index 49f834ecb..b542e42a2 100644 --- a/docs/narr/renderers.rst +++ b/docs/narr/renderers.rst @@ -57,11 +57,12 @@ values from Python dictionaries so, in practice, view callables which use renderers return Python dictionaries. View callables can :ref:`explicitly call -` renderers; but typically view -configuration declares the renderer used to render a view callable's -results. This is done with the ``renderer`` attribute. For example, -this call to :meth:`~pyramid.config.Configurator.add_view` associates -the ``json`` renderer with a view callable: +` renderers, but they typically +don't. Instead view configuration declares the renderer used to +render a view callable's results. This is done with the ``renderer`` +attribute. For example, this call to +:meth:`~pyramid.config.Configurator.add_view` associates the ``json`` +renderer with a view callable: .. code-block:: python -- cgit v1.2.3 From 0681d5798574d5f3ed644bf56086208c8571e0b9 Mon Sep 17 00:00:00 2001 From: "Karl O. Pinc" Date: Mon, 7 Oct 2013 16:12:27 -0500 Subject: Docs: renders.rst: Make sentences short per IRC chat with committers. --- docs/narr/renderers.rst | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/docs/narr/renderers.rst b/docs/narr/renderers.rst index b542e42a2..7c25386f5 100644 --- a/docs/narr/renderers.rst +++ b/docs/narr/renderers.rst @@ -56,13 +56,11 @@ serialization techniques. In practice, renderers obtain application data values from Python dictionaries so, in practice, view callables which use renderers return Python dictionaries. -View callables can :ref:`explicitly call -` renderers, but they typically -don't. Instead view configuration declares the renderer used to -render a view callable's results. This is done with the ``renderer`` -attribute. For example, this call to -:meth:`~pyramid.config.Configurator.add_view` associates the ``json`` -renderer with a view callable: +View callables can :ref:`explicitly call ` +renderers. Typically view configuration declares the renderer used to render +a view callable's results. This is done with the ``renderer`` attribute. +For example, this call to :meth:`~pyramid.config.Configurator.add_view` +associates the ``json`` renderer with a view callable: .. code-block:: python -- cgit v1.2.3 From a26d09f291bdf4f9c7853b1dbfc9643a678a7b94 Mon Sep 17 00:00:00 2001 From: "Karl O. Pinc" Date: Mon, 7 Oct 2013 16:29:31 -0500 Subject: Docs: renders.rst: Make sentences that everybody's happy with. --- docs/narr/renderers.rst | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/docs/narr/renderers.rst b/docs/narr/renderers.rst index 7c25386f5..740c81555 100644 --- a/docs/narr/renderers.rst +++ b/docs/narr/renderers.rst @@ -57,10 +57,11 @@ values from Python dictionaries so, in practice, view callables which use renderers return Python dictionaries. View callables can :ref:`explicitly call ` -renderers. Typically view configuration declares the renderer used to render -a view callable's results. This is done with the ``renderer`` attribute. -For example, this call to :meth:`~pyramid.config.Configurator.add_view` -associates the ``json`` renderer with a view callable: +renderers, but typically don't. Instead view configuration declares the +renderer used to render a view callable's results. This is done with the +``renderer`` attribute. For example, this call to +:meth:`~pyramid.config.Configurator.add_view` associates the ``json`` +renderer with a view callable: .. code-block:: python -- cgit v1.2.3 From 13cf2dd2c912c1961d429c8a5756622cf960d5bf Mon Sep 17 00:00:00 2001 From: Michael Merickel Date: Mon, 7 Oct 2013 19:14:49 -0500 Subject: fix some broken positional args to sqlalchemy models --- docs/tutorials/wiki2/src/authorization/tutorial/scripts/initializedb.py | 2 +- docs/tutorials/wiki2/src/models/tutorial/scripts/initializedb.py | 2 +- docs/tutorials/wiki2/src/tests/tutorial/scripts/initializedb.py | 2 +- docs/tutorials/wiki2/src/views/tutorial/scripts/initializedb.py | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/tutorials/wiki2/src/authorization/tutorial/scripts/initializedb.py b/docs/tutorials/wiki2/src/authorization/tutorial/scripts/initializedb.py index 092e359ce..23a5f13f4 100644 --- a/docs/tutorials/wiki2/src/authorization/tutorial/scripts/initializedb.py +++ b/docs/tutorials/wiki2/src/authorization/tutorial/scripts/initializedb.py @@ -33,5 +33,5 @@ def main(argv=sys.argv): DBSession.configure(bind=engine) Base.metadata.create_all(engine) with transaction.manager: - model = Page('FrontPage', 'This is the front page') + model = Page(name='FrontPage', data='This is the front page') DBSession.add(model) diff --git a/docs/tutorials/wiki2/src/models/tutorial/scripts/initializedb.py b/docs/tutorials/wiki2/src/models/tutorial/scripts/initializedb.py index 092e359ce..23a5f13f4 100644 --- a/docs/tutorials/wiki2/src/models/tutorial/scripts/initializedb.py +++ b/docs/tutorials/wiki2/src/models/tutorial/scripts/initializedb.py @@ -33,5 +33,5 @@ def main(argv=sys.argv): DBSession.configure(bind=engine) Base.metadata.create_all(engine) with transaction.manager: - model = Page('FrontPage', 'This is the front page') + model = Page(name='FrontPage', data='This is the front page') DBSession.add(model) diff --git a/docs/tutorials/wiki2/src/tests/tutorial/scripts/initializedb.py b/docs/tutorials/wiki2/src/tests/tutorial/scripts/initializedb.py index 092e359ce..23a5f13f4 100644 --- a/docs/tutorials/wiki2/src/tests/tutorial/scripts/initializedb.py +++ b/docs/tutorials/wiki2/src/tests/tutorial/scripts/initializedb.py @@ -33,5 +33,5 @@ def main(argv=sys.argv): DBSession.configure(bind=engine) Base.metadata.create_all(engine) with transaction.manager: - model = Page('FrontPage', 'This is the front page') + model = Page(name='FrontPage', data='This is the front page') DBSession.add(model) diff --git a/docs/tutorials/wiki2/src/views/tutorial/scripts/initializedb.py b/docs/tutorials/wiki2/src/views/tutorial/scripts/initializedb.py index 092e359ce..23a5f13f4 100644 --- a/docs/tutorials/wiki2/src/views/tutorial/scripts/initializedb.py +++ b/docs/tutorials/wiki2/src/views/tutorial/scripts/initializedb.py @@ -33,5 +33,5 @@ def main(argv=sys.argv): DBSession.configure(bind=engine) Base.metadata.create_all(engine) with transaction.manager: - model = Page('FrontPage', 'This is the front page') + model = Page(name='FrontPage', data='This is the front page') DBSession.add(model) -- cgit v1.2.3 From 56170f30f6cd1d4268d9e5b0cd24a75c645ab0ca Mon Sep 17 00:00:00 2001 From: "Karl O. Pinc" Date: Mon, 7 Oct 2013 21:00:26 -0500 Subject: Docs: project.rst: Reword template reload note per Steve Piercy's suggestions. Take care to retain the thought that the defaults setup by the scaffold cause automatic template reload. This patch should be applied before the docs_dict_note branch. --- docs/narr/project.rst | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/docs/narr/project.rst b/docs/narr/project.rst index 9451f41b1..0de46c806 100644 --- a/docs/narr/project.rst +++ b/docs/narr/project.rst @@ -886,15 +886,16 @@ returns the HTML in a :term:`response`. See :ref:`views_which_use_a_renderer` for more information about how views, renderers, and templates relate and cooperate. -.. note:: Because our ``development.ini`` has a ``pyramid.reload_templates = - true`` directive indicating that templates should be reloaded when - they change, you won't need to restart the application server to - see changes you make to templates. During development, this is - handy. If this directive had been ``false`` (or if the directive - did not exist), you would need to restart the application server - for each template change. For production applications, you should - set your project's ``pyramid.reload_templates`` to ``false`` to increase - the speed at which templates may be rendered. +.. note:: ``development.ini`` has a setting that controls how templates are + reloaded: ``pyramid.reload_templates``. + + - A setting of ``True`` (as in the scaffold ``development.ini``) + automatically reloads changed templates without a server restart. This + is convenient while developing but slows template rendering speed. + + - A setting of ``False`` (the default) requires a server restart to + integrate template changes. Production applications should set + ``pyramid.reload_templates = False``. .. index:: single: static directory -- cgit v1.2.3 From 8e1e6914945a5a3d05f49f0e32b7152182b23767 Mon Sep 17 00:00:00 2001 From: "Karl O. Pinc" Date: Mon, 7 Oct 2013 22:20:26 -0500 Subject: Docs: introduction.rst: Note that printf() works. --- docs/narr/introduction.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/narr/introduction.rst b/docs/narr/introduction.rst index 9ec26f276..b60934ebb 100644 --- a/docs/narr/introduction.rst +++ b/docs/narr/introduction.rst @@ -182,7 +182,8 @@ Fully Interactive Development When developing a Pyramid application a variety of interactive features are available. Pyramid can automatically utilize changed templates when rendering pages and automatically restart the -application to incorporate changed python code. +application to incorporate changed python code. Plain old ``printf()`` +calls used for debugging can display to a console. Pyramid's debug toolbar comes activated when you use a Pyramid scaffold to render a project. This toolbar overlays your application in the browser, and -- cgit v1.2.3 From 5ded35a5d057eb6188d6f80c47593ec934833d47 Mon Sep 17 00:00:00 2001 From: Steve Piercy Date: Mon, 7 Oct 2013 21:32:14 -0700 Subject: - straighten out difference between content and its presentation, re: admonitions of note, seealse, sidebar --- docs/narr/project.rst | 79 +++++++++++++++++++++------------------------------ 1 file changed, 33 insertions(+), 46 deletions(-) diff --git a/docs/narr/project.rst b/docs/narr/project.rst index b4397c09b..fcce9fac4 100644 --- a/docs/narr/project.rst +++ b/docs/narr/project.rst @@ -146,7 +146,7 @@ puts his projects in ``C:\projects``. .. warning:: - You’ll need to avoid using ``pcreate`` to create a project with the same + You'll need to avoid using ``pcreate`` to create a project with the same name as a Python standard library component. In particular, this means you should avoid using the names ``site`` or ``test``, both of which conflict with Python standard library packages. You should also avoid @@ -210,12 +210,6 @@ Python interpreter from the :term:`virtualenv` you created during :ref:`installing_chapter` (the ``python`` command that lives in the ``bin`` directory of your virtualenv). -.. sidebar:: Verbose Testing - - The ``-q`` option is passed to the ``setup.py test`` command to limit the - output to a stream of dots. If you don't pass ``-q``, you'll see more - verbose test result output (which normally isn't very useful). - On UNIX: .. code-block:: text @@ -253,6 +247,12 @@ The tests themselves are found in the ``tests.py`` module in your ``pcreate`` generated project. Within a project generated by the ``starter`` scaffold, a single sample test exists. +.. note:: + + The ``-q`` option is passed to the ``setup.py test`` command to limit the + output to a stream of dots. If you don't pass ``-q``, you'll see more + verbose test result output (which normally isn't very useful). + .. index:: single: running an application single: pserve @@ -684,14 +684,6 @@ use a different version control system, you may need to install a setuptools add-on such as ``setuptools-git`` or ``setuptools-hg`` for this behavior to work properly. -.. sidebar:: Python's ``setup.py`` - - ``setup.py`` is the de facto standard which Python developers use to - distribute their reusable code. You can read more about ``setup.py`` files - and their usage in the `Setuptools documentation - `_ and `The - Hitchhiker's Guide to Packaging `_. - .. index:: single: setup.py @@ -702,6 +694,14 @@ The ``setup.py`` file is a :term:`setuptools` setup file. It is meant to be run directly from the command line to perform a variety of functions, such as testing, packaging, and distributing your application. +.. note:: + + ``setup.py`` is the de facto standard which Python developers use to + distribute their reusable code. You can read more about ``setup.py`` files + and their usage in the `Setuptools documentation + `_ and `The + Hitchhiker's Guide to Packaging `_. + Our generated ``setup.py`` looks like this: .. literalinclude:: MyProject/setup.py @@ -857,26 +857,6 @@ and which returns a :term:`response`. :language: python :linenos: -.. sidebar:: Fully Interactive Development - - Because our ``development.ini`` has a ``pyramid.reload_templates = - true`` directive indicating that templates should be reloaded when - they change, you won't need to restart the application server to - see changes you make to templates. During development, this is - handy. If this directive had been ``false`` (or if the directive - did not exist), you would need to restart the application server - for each template change. For production applications, you should - set your project's ``pyramid.reload_templates`` to ``false`` to - increase template rendering speed. - - Pyramid can also dynamically reload changed Python files. For more - on this see :ref:`reloading_code` above. - - The :ref:`debug_toolbar` provides interactive access to your - application's internals and, should an exception occur, allows - interactive access to traceback execution stack frames from the - Python interpreter. - 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``). @@ -905,20 +885,27 @@ returns the HTML in a :term:`response`. .. note:: Dictionaries provide values to :term:`template`\s. -See :ref:`views_which_use_a_renderer` for more information about how views, -renderers, and templates relate and cooperate. - .. note:: ``development.ini`` has a setting that controls how templates are - reloaded: ``pyramid.reload_templates``. - - - A setting of ``True`` (as in the scaffold ``development.ini``) - automatically reloads changed templates without a server restart. This - is convenient while developing but slows template rendering speed. - - - A setting of ``False`` (the default) requires a server restart to - integrate template changes. Production applications should set + reloaded, ``pyramid.reload_templates``. + + - When set to ``True`` (as in the scaffold ``development.ini``) changed + templates automatically reload without a server restart. This is + convenient while developing, but slows template rendering speed. + + - When set to ``False`` (the default value), changing templates requires + a server restart to reload them. Production applications should use ``pyramid.reload_templates = False``. +.. seealso:: See also :ref:`views_which_use_a_renderer` for more information + about how views, renderers, and templates relate and cooperate. + +.. seealso:: Pyramid can also dynamically reload changed Python files. For + more on this see :ref:`reloading_code`. + +.. seealso:: The :ref:`debug_toolbar` provides interactive access to your + application's internals and, should an exception occur, allows interactive + access to traceback execution stack frames from the Python interpreter. + .. index:: single: static directory -- cgit v1.2.3 From d84407421d1830ed726bcc280b3de112aca701e7 Mon Sep 17 00:00:00 2001 From: Steve Piercy Date: Mon, 7 Oct 2013 21:40:10 -0700 Subject: wrap to 79 --- docs/narr/introduction.rst | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/narr/introduction.rst b/docs/narr/introduction.rst index b60934ebb..ece720a97 100644 --- a/docs/narr/introduction.rst +++ b/docs/narr/introduction.rst @@ -179,11 +179,11 @@ Example: :ref:`static_assets_section`. Fully Interactive Development ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -When developing a Pyramid application a variety of interactive -features are available. Pyramid can automatically utilize changed -templates when rendering pages and automatically restart the -application to incorporate changed python code. Plain old ``printf()`` -calls used for debugging can display to a console. +When developing a Pyramid application, several interactive features are +available. Pyramid can automatically utilize changed templates when rendering +pages and automatically restart the application to incorporate changed python +code. Plain old ``printf()`` calls used for debugging can display to a +console. Pyramid's debug toolbar comes activated when you use a Pyramid scaffold to render a project. This toolbar overlays your application in the browser, and @@ -790,7 +790,7 @@ automate some of the tedium away: for method in ('GET', 'POST', 'HEAD'): view = getattr(module, 'xhr_%s_view' % method, None) if view is not None: - config.add_view(view, route_name='xhr_route', xhr=True, + config.add_view(view, route_name='xhr_route', xhr=True, permission='view', request_method=method) config = Configurator() -- cgit v1.2.3 From 716bdf37573ee8ef295ac1d01a1e8ff96c4c0f43 Mon Sep 17 00:00:00 2001 From: Steve Piercy Date: Mon, 7 Oct 2013 21:55:30 -0700 Subject: - use clearer subject --- docs/narr/project.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/narr/project.rst b/docs/narr/project.rst index fcce9fac4..8b7c24725 100644 --- a/docs/narr/project.rst +++ b/docs/narr/project.rst @@ -984,9 +984,9 @@ named ``views`` instead of within a single ``views.py`` file, you might: can be empty. This just tells Python that the ``views`` directory is a *package*.) -- *Move* the existing ``views.py`` file to a file inside the new ``views`` - directory named, say, ``blog.py``. Because the ``templates`` directory - remains in the ``myproject`` package, the template :term:`asset +- *Move* the content from the existing ``views.py`` file to a file inside the + new ``views`` directory named, say, ``blog.py``. Because the ``templates`` + directory remains in the ``myproject`` package, the template :term:`asset specification` values in ``blog.py`` must now be fully qualified with the project's package name (``myproject:templates/blog.pt``). -- cgit v1.2.3 From 6a3eed4ddc4178d19c0002ec72b9a1d6494e01ae Mon Sep 17 00:00:00 2001 From: Steve Piercy Date: Tue, 8 Oct 2013 00:40:15 -0700 Subject: - remove . from end of URL --- docs/conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/conf.py b/docs/conf.py index f18cf3ec3..ec62faa99 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -458,4 +458,4 @@ epub_exclude_files = ['_static/opensearch.xml', '_static/doctools.js', # The depth of the table of contents in toc.ncx. epub_tocdepth = 3 -# For a list of all settings, visit http://sphinx-doc.org/config.html. +# For a list of all settings, visit http://sphinx-doc.org/config.html -- cgit v1.2.3 From 4223668ee4c0d0ac0e981f3241d56ffa805ba6d1 Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Tue, 8 Oct 2013 12:46:21 +0200 Subject: remove unused renderer arg --- CHANGES.txt | 2 ++ pyramid/config/routes.py | 1 - 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGES.txt b/CHANGES.txt index 051328a02..6e73de823 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -21,6 +21,8 @@ Bug Fixes allowing traversal to continue. See https://github.com/Pylons/pyramid/issues/1104 +- Remove unused ``renderer`` argument from ``Configurator.add_route``. + Documentation ------------- diff --git a/pyramid/config/routes.py b/pyramid/config/routes.py index 9dca9e51e..4de4663a8 100644 --- a/pyramid/config/routes.py +++ b/pyramid/config/routes.py @@ -36,7 +36,6 @@ class RoutesConfiguratorMixin(object): request_param=None, traverse=None, custom_predicates=(), - renderer=None, use_global_views=False, path=None, pregenerator=None, -- cgit v1.2.3 From eb3b27df0a35088f631680d7f467680662f17bac Mon Sep 17 00:00:00 2001 From: "Karl O. Pinc" Date: Tue, 8 Oct 2013 06:17:13 -0500 Subject: Docs: project.rst: Printf()s can be used for debugging. Output goes to the server console. The main point of the second sentence is to setup the reader with mental context for the 3rd sentence, so that the 3rd sentence sinks in. Likewise, the parenthetical in the second sentence about server startup messages gives the reader some clue as to what the rest of the sentence it talking about. I suspect that some readers won't know what a console is, and the rest will be confused by a server run on a console. --- docs/narr/project.rst | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/docs/narr/project.rst b/docs/narr/project.rst index 8b7c24725..a454573f0 100644 --- a/docs/narr/project.rst +++ b/docs/narr/project.rst @@ -259,6 +259,8 @@ single sample test exists. single: reload single: startup +.. _running_the_project_application: + Running The Project Application ------------------------------- @@ -600,6 +602,8 @@ server which listens on TCP port 6543. It is configured to listen on all interfaces (``0.0.0.0``). This means that any remote system which has TCP access to your system can see your Pyramid application. +.. _MyProject_ini_logging: + The sections that live between the markers ``# Begin logging configuration`` and ``# End logging configuration`` represent Python's standard library :mod:`logging` module configuration for your application. The sections @@ -885,6 +889,14 @@ returns the HTML in a :term:`response`. .. note:: Dictionaries provide values to :term:`template`\s. +.. note:: When the application is run with the scaffold's :ref:`default + development.ini ` configuration :ref:`logging is setup + ` to aid debugging. Should an exception be raised, + uncaught tracebacks are displayed, after the startup messages, on :ref:`the + console running the server `. + Conveniently, ``printf()``\s inserted into the application for debugging + also send output to this console. + .. note:: ``development.ini`` has a setting that controls how templates are reloaded, ``pyramid.reload_templates``. -- cgit v1.2.3 From fd99b0e53835dd7463986c4d705e8de06be7dbe6 Mon Sep 17 00:00:00 2001 From: "Karl O. Pinc" Date: Tue, 8 Oct 2013 09:16:10 -0500 Subject: Docs: project.rst: Oops, print(), not printf(). --- docs/narr/project.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/narr/project.rst b/docs/narr/project.rst index a454573f0..9a15649d7 100644 --- a/docs/narr/project.rst +++ b/docs/narr/project.rst @@ -894,7 +894,7 @@ returns the HTML in a :term:`response`. ` to aid debugging. Should an exception be raised, uncaught tracebacks are displayed, after the startup messages, on :ref:`the console running the server `. - Conveniently, ``printf()``\s inserted into the application for debugging + Conveniently, ``print()``\s inserted into the application for debugging also send output to this console. .. note:: ``development.ini`` has a setting that controls how templates are -- cgit v1.2.3 From 2004173e4f1614b8eb9cc3534ec3117c736ff009 Mon Sep 17 00:00:00 2001 From: "Karl O. Pinc" Date: Tue, 8 Oct 2013 09:37:39 -0500 Subject: Docs: introduction.rst: Beaker -> Redis. --- docs/narr/introduction.rst | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/narr/introduction.rst b/docs/narr/introduction.rst index ece720a97..4e705b8b1 100644 --- a/docs/narr/introduction.rst +++ b/docs/narr/introduction.rst @@ -418,12 +418,12 @@ Sessions Pyramid has built-in HTTP sessioning. This allows you to associate data with otherwise anonymous users between requests. Lots of systems do this. But -Pyramid also allows you to plug in your own sessioning system by creating -some code that adheres to a documented interface. Currently there is a -binding package for the third-party Beaker sessioning system that does exactly -this. But if you have a specialized need (perhaps you want to store your -session data in MongoDB), you can. You can even switch between -implementations without changing your application code. +Pyramid also allows you to plug in your own sessioning system by creating some +code that adheres to a documented interface. Currently there is a binding +package for the third-party Redis sessioning system that does exactly this. +But if you have a specialized need (perhaps you want to store your session data +in MongoDB), you can. You can even switch between implementations without +changing your application code. Example: :ref:`sessions_chapter`. -- cgit v1.2.3 From 4bc489d00bcb6013db1e9da00c3c16809eeb90fc Mon Sep 17 00:00:00 2001 From: Steve Piercy Date: Tue, 8 Oct 2013 11:17:18 -0700 Subject: print() not printf() --- docs/narr/introduction.rst | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/docs/narr/introduction.rst b/docs/narr/introduction.rst index ece720a97..bb2d85e94 100644 --- a/docs/narr/introduction.rst +++ b/docs/narr/introduction.rst @@ -180,10 +180,9 @@ Fully Interactive Development ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ When developing a Pyramid application, several interactive features are -available. Pyramid can automatically utilize changed templates when rendering +available. Pyramid can automatically utilize changed templates when rendering pages and automatically restart the application to incorporate changed python -code. Plain old ``printf()`` calls used for debugging can display to a -console. +code. Plain old ``print()`` calls used for debugging can display to a console. Pyramid's debug toolbar comes activated when you use a Pyramid scaffold to render a project. This toolbar overlays your application in the browser, and -- cgit v1.2.3 From a2b15855bee4893524609a941954c823bfbcec0d Mon Sep 17 00:00:00 2001 From: Paul Everitt Date: Tue, 8 Oct 2013 14:33:16 -0400 Subject: Small quick tutorial fixes post conference. --- docs/quick_tutorial/databases.rst | 11 +-- .../debugtoolbar/tutorial/__init__.py | 4 +- docs/quick_tutorial/ini.rst | 2 +- docs/quick_tutorial/jinja2.rst | 7 +- docs/quick_tutorial/jinja2/development.ini | 1 - docs/quick_tutorial/jinja2/tutorial/__init__.py | 1 + docs/quick_tutorial/more_view_classes.rst | 2 +- docs/quick_tutorial/requirements.rst | 2 +- docs/quick_tutorial/retail_forms/development.ini | 41 +++++++++ docs/quick_tutorial/retail_forms/setup.py | 15 ++++ .../retail_forms/tutorial/__init__.py | 13 +++ docs/quick_tutorial/retail_forms/tutorial/tests.py | 36 ++++++++ docs/quick_tutorial/retail_forms/tutorial/views.py | 96 ++++++++++++++++++++++ .../retail_forms/tutorial/wiki_view.pt | 19 +++++ .../retail_forms/tutorial/wikipage_addedit.pt | 37 +++++++++ .../retail_forms/tutorial/wikipage_view.pt | 17 ++++ docs/quick_tutorial/unit_testing.rst | 2 +- docs/quick_tutorial/views.rst | 2 +- 18 files changed, 286 insertions(+), 22 deletions(-) create mode 100644 docs/quick_tutorial/retail_forms/development.ini create mode 100644 docs/quick_tutorial/retail_forms/setup.py create mode 100644 docs/quick_tutorial/retail_forms/tutorial/__init__.py create mode 100644 docs/quick_tutorial/retail_forms/tutorial/tests.py create mode 100644 docs/quick_tutorial/retail_forms/tutorial/views.py create mode 100644 docs/quick_tutorial/retail_forms/tutorial/wiki_view.pt create mode 100644 docs/quick_tutorial/retail_forms/tutorial/wikipage_addedit.pt create mode 100644 docs/quick_tutorial/retail_forms/tutorial/wikipage_view.pt diff --git a/docs/quick_tutorial/databases.rst b/docs/quick_tutorial/databases.rst index 93a02ffc7..20b3cd46d 100644 --- a/docs/quick_tutorial/databases.rst +++ b/docs/quick_tutorial/databases.rst @@ -39,15 +39,6 @@ Objectives Steps ===== -.. warning:: - - Your Python might not have SQLite bundled. If not, install it into - your virtual environment with: - - .. code-block:: bash - - $ $VENV/bin/easy_install sphinx pysqlite - #. We are going to use the forms step as our starting point: .. code-block:: bash @@ -97,7 +88,7 @@ Steps .. code-block:: bash - $ initialize_tutorial_db development.ini + $ $VENV/bin/initialize_tutorial_db development.ini 2013-09-06 15:54:08,050 INFO [sqlalchemy.engine.base.Engine][MainThread] PRAGMA table_info("wikipages") 2013-09-06 15:54:08,050 INFO [sqlalchemy.engine.base.Engine][MainThread] () 2013-09-06 15:54:08,051 INFO [sqlalchemy.engine.base.Engine][MainThread] diff --git a/docs/quick_tutorial/debugtoolbar/tutorial/__init__.py b/docs/quick_tutorial/debugtoolbar/tutorial/__init__.py index 2b4e84f30..0993b25be 100644 --- a/docs/quick_tutorial/debugtoolbar/tutorial/__init__.py +++ b/docs/quick_tutorial/debugtoolbar/tutorial/__init__.py @@ -3,11 +3,11 @@ from pyramid.response import Response def hello_world(request): - return Response('

Hello World!

') + return xResponse('

Hello World!

') def main(global_config, **settings): config = Configurator(settings=settings) config.add_route('hello', '/') config.add_view(hello_world, route_name='hello') - return config.make_wsgi_app() \ No newline at end of file + return config.make_wsgi_app() diff --git a/docs/quick_tutorial/ini.rst b/docs/quick_tutorial/ini.rst index 630b1faa5..618b8e5e8 100644 --- a/docs/quick_tutorial/ini.rst +++ b/docs/quick_tutorial/ini.rst @@ -46,7 +46,7 @@ Steps :linenos: #. We can now install our project, thus generating (or re-generating) an - "egg" at ``ini/tutorial.egg-info``: + "egg" at ``ini/tutorial.egg-info``: .. code-block:: bash diff --git a/docs/quick_tutorial/jinja2.rst b/docs/quick_tutorial/jinja2.rst index 40d941098..44d9f635b 100644 --- a/docs/quick_tutorial/jinja2.rst +++ b/docs/quick_tutorial/jinja2.rst @@ -29,11 +29,10 @@ Steps $ $VENV/bin/python setup.py develop $ $VENV/bin/easy_install pyramid_jinja2 -#. We need to add an item to ``pyramid.includes`` in - ``jinja2/development.ini``: +#. We need to include ``pyramid_jinja2`` in + ``jinja2/tutorial/__init__.py``: - .. literalinclude:: jinja2/development.ini - :language: ini + .. literalinclude:: jinja2/tutorial/__init__.py :linenos: #. Our ``jinja2/tutorial/views.py`` simply changes its ``renderer``: diff --git a/docs/quick_tutorial/jinja2/development.ini b/docs/quick_tutorial/jinja2/development.ini index c096fa936..62e0c5123 100644 --- a/docs/quick_tutorial/jinja2/development.ini +++ b/docs/quick_tutorial/jinja2/development.ini @@ -3,7 +3,6 @@ use = egg:tutorial pyramid.reload_templates = true pyramid.includes = pyramid_debugtoolbar - pyramid_jinja2 [server:main] use = egg:pyramid#wsgiref diff --git a/docs/quick_tutorial/jinja2/tutorial/__init__.py b/docs/quick_tutorial/jinja2/tutorial/__init__.py index 013d4538f..1f6783c06 100644 --- a/docs/quick_tutorial/jinja2/tutorial/__init__.py +++ b/docs/quick_tutorial/jinja2/tutorial/__init__.py @@ -3,6 +3,7 @@ from pyramid.config import Configurator def main(global_config, **settings): config = Configurator(settings=settings) + config.include('pyramid_jinja2') config.add_route('home', '/') config.add_route('hello', '/howdy') config.scan('.views') diff --git a/docs/quick_tutorial/more_view_classes.rst b/docs/quick_tutorial/more_view_classes.rst index 2792869ac..21b353b7c 100644 --- a/docs/quick_tutorial/more_view_classes.rst +++ b/docs/quick_tutorial/more_view_classes.rst @@ -166,7 +166,7 @@ Extra Credit #. The ``edit`` and ``delete`` views are both submitted to with ``POST``. Why does the ``edit`` view configuration not catch the - the ``POST`` used by ``delete``? + ``POST`` used by ``delete``? #. We used Python ``@property`` on ``full_name``. If we reference this many times in a template or view code, it would re-compute this diff --git a/docs/quick_tutorial/requirements.rst b/docs/quick_tutorial/requirements.rst index 40e818807..234e4aa0d 100644 --- a/docs/quick_tutorial/requirements.rst +++ b/docs/quick_tutorial/requirements.rst @@ -226,7 +226,7 @@ during this tutorial: # Mac and Linux $ $VENV/bin/easy_install nose webtest deform sqlalchemy \ pyramid_chameleon pyramid_debugtoolbar waitress \ - pyramid_jinja2 pyramid_tm zope.sqlalchemy pysqlite + pyramid_jinja2 pyramid_tm zope.sqlalchemy # Windows c:\> %VENV%\Scripts\easy_install nose webtest deform sqlalchemy pyramid_chameleon diff --git a/docs/quick_tutorial/retail_forms/development.ini b/docs/quick_tutorial/retail_forms/development.ini new file mode 100644 index 000000000..62e0c5123 --- /dev/null +++ b/docs/quick_tutorial/retail_forms/development.ini @@ -0,0 +1,41 @@ +[app:main] +use = egg:tutorial +pyramid.reload_templates = true +pyramid.includes = + pyramid_debugtoolbar + +[server:main] +use = egg:pyramid#wsgiref +host = 0.0.0.0 +port = 6543 + +# Begin logging configuration + +[loggers] +keys = root, tutorial + +[logger_tutorial] +level = DEBUG +handlers = +qualname = tutorial + +[handlers] +keys = console + +[formatters] +keys = generic + +[logger_root] +level = INFO +handlers = console + +[handler_console] +class = StreamHandler +args = (sys.stderr,) +level = NOTSET +formatter = generic + +[formatter_generic] +format = %(asctime)s %(levelname)-5.5s [%(name)s][%(threadName)s] %(message)s + +# End logging configuration diff --git a/docs/quick_tutorial/retail_forms/setup.py b/docs/quick_tutorial/retail_forms/setup.py new file mode 100644 index 000000000..361ade013 --- /dev/null +++ b/docs/quick_tutorial/retail_forms/setup.py @@ -0,0 +1,15 @@ +from setuptools import setup + +requires = [ + 'pyramid', + 'pyramid_chameleon', + 'deform' +] + +setup(name='tutorial', + install_requires=requires, + entry_points="""\ + [paste.app_factory] + main = tutorial:main + """, +) \ No newline at end of file diff --git a/docs/quick_tutorial/retail_forms/tutorial/__init__.py b/docs/quick_tutorial/retail_forms/tutorial/__init__.py new file mode 100644 index 000000000..dff7457cf --- /dev/null +++ b/docs/quick_tutorial/retail_forms/tutorial/__init__.py @@ -0,0 +1,13 @@ +from pyramid.config import Configurator + + +def main(global_config, **settings): + config = Configurator(settings=settings) + config.include('pyramid_chameleon') + config.add_route('wiki_view', '/') + config.add_route('wikipage_add', '/add') + config.add_route('wikipage_view', '/{uid}') + config.add_route('wikipage_edit', '/{uid}/edit') + config.add_static_view('deform_static', 'deform:static/') + config.scan('.views') + return config.make_wsgi_app() diff --git a/docs/quick_tutorial/retail_forms/tutorial/tests.py b/docs/quick_tutorial/retail_forms/tutorial/tests.py new file mode 100644 index 000000000..5a2c40904 --- /dev/null +++ b/docs/quick_tutorial/retail_forms/tutorial/tests.py @@ -0,0 +1,36 @@ +import unittest + +from pyramid import testing + + +class TutorialViewTests(unittest.TestCase): + def setUp(self): + self.config = testing.setUp() + + def tearDown(self): + testing.tearDown() + + def test_home(self): + from .views import WikiViews + + request = testing.DummyRequest() + inst = WikiViews(request) + response = inst.wiki_view() + self.assertEqual(len(response['pages']), 3) + + +class TutorialFunctionalTests(unittest.TestCase): + def setUp(self): + from tutorial import main + + app = main({}) + from webtest import TestApp + + self.testapp = TestApp(app) + + def tearDown(self): + testing.tearDown() + + def test_home(self): + res = self.testapp.get('/', status=200) + self.assertIn(b'Wiki: View', res.body) diff --git a/docs/quick_tutorial/retail_forms/tutorial/views.py b/docs/quick_tutorial/retail_forms/tutorial/views.py new file mode 100644 index 000000000..2737ebdc4 --- /dev/null +++ b/docs/quick_tutorial/retail_forms/tutorial/views.py @@ -0,0 +1,96 @@ +import colander +import deform.widget + +from pyramid.httpexceptions import HTTPFound +from pyramid.view import view_config + +pages = { + '100': dict(uid='100', title='Page 100', body='100'), + '101': dict(uid='101', title='Page 101', body='101'), + '102': dict(uid='102', title='Page 102', body='102') +} + +class WikiPage(colander.MappingSchema): + title = colander.SchemaNode(colander.String()) + body = colander.SchemaNode( + colander.String(), + widget=deform.widget.RichTextWidget() + ) + + +class WikiViews(object): + def __init__(self, request): + self.request = request + + @property + def wiki_form(self): + schema = WikiPage() + return deform.Form(schema, buttons=('submit',)) + + @property + def reqts(self): + return self.wiki_form.get_widget_resources() + + @view_config(route_name='wiki_view', renderer='wiki_view.pt') + def wiki_view(self): + return dict(pages=pages.values()) + + @view_config(route_name='wikipage_add', + renderer='wikipage_addedit.pt') + def wikipage_add(self): + form = self.wiki_form + + if 'submit' in self.request.params: + controls = self.request.POST.items() + try: + appstruct = self.wiki_form.validate(controls) + except deform.ValidationFailure as e: + # Form is NOT valid + return dict(form=e.render()) + + # Form is valid, make a new identifier and add to list + last_uid = int(sorted(pages.keys())[-1]) + new_uid = str(last_uid + 1) + pages[new_uid] = dict( + uid=new_uid, title=appstruct['title'], + body=appstruct['body'] + ) + + # Now visit new page + url = self.request.route_url('wikipage_view', uid=new_uid) + return HTTPFound(url) + + return dict(form=form) + + @view_config(route_name='wikipage_view', renderer='wikipage_view.pt') + def wikipage_view(self): + uid = self.request.matchdict['uid'] + page = pages[uid] + return dict(page=page) + + @view_config(route_name='wikipage_edit', + renderer='wikipage_addedit.pt') + def wikipage_edit(self): + uid = self.request.matchdict['uid'] + page = pages[uid] + + wiki_form = self.wiki_form + + if 'submit' in self.request.params: + controls = self.request.POST.items() + try: + appstruct = wiki_form.validate(controls) + except deform.ValidationFailure as e: + return dict(page=page, form=e.render()) + + # Change the content and redirect to the view + page['title'] = appstruct['title'] + page['body'] = appstruct['body'] + + url = self.request.route_url('wikipage_view', + uid=page['uid']) + return HTTPFound(url) + + form = wiki_form.render(page) + + return dict(page=page, form=form) \ No newline at end of file diff --git a/docs/quick_tutorial/retail_forms/tutorial/wiki_view.pt b/docs/quick_tutorial/retail_forms/tutorial/wiki_view.pt new file mode 100644 index 000000000..9e3afe495 --- /dev/null +++ b/docs/quick_tutorial/retail_forms/tutorial/wiki_view.pt @@ -0,0 +1,19 @@ + + + + Wiki: View + + +

Wiki

+ +Add + WikiPage + + + \ No newline at end of file diff --git a/docs/quick_tutorial/retail_forms/tutorial/wikipage_addedit.pt b/docs/quick_tutorial/retail_forms/tutorial/wikipage_addedit.pt new file mode 100644 index 000000000..586f4c44b --- /dev/null +++ b/docs/quick_tutorial/retail_forms/tutorial/wikipage_addedit.pt @@ -0,0 +1,37 @@ + + + + WikiPage: Add/Edit + + + + + + + + +

Wiki

+ +
+
+ ${structure:field.title} + * +
+
+ ${structure:field.serialize()} +
+
    +
  • + ${structure:error} +
  • +
+
+ + + + diff --git a/docs/quick_tutorial/retail_forms/tutorial/wikipage_view.pt b/docs/quick_tutorial/retail_forms/tutorial/wikipage_view.pt new file mode 100644 index 000000000..cb9ff526e --- /dev/null +++ b/docs/quick_tutorial/retail_forms/tutorial/wikipage_view.pt @@ -0,0 +1,17 @@ + + + + WikiPage: View + + + + Up + | + + Edit + + +

${page.title}

+

${structure: page.body}

+ + \ No newline at end of file diff --git a/docs/quick_tutorial/unit_testing.rst b/docs/quick_tutorial/unit_testing.rst index 73b33c588..ed33f62d7 100644 --- a/docs/quick_tutorial/unit_testing.rst +++ b/docs/quick_tutorial/unit_testing.rst @@ -77,7 +77,7 @@ some ``pyramid.testing`` helpers which we use in the test setup and teardown. Our one test imports the view, makes a dummy request, and sees if the view returns what we expected. -The ``tests.HelloWorldViewTests.test_hello_world`` test is a small +The ``tests.TutorialViewTests.test_hello_world`` test is a small example of a unit test. First, we import the view inside each test. Why not import at the top, like in normal Python code? Because imports can cause effects that break a test. We'd like our tests to be in *units*, diff --git a/docs/quick_tutorial/views.rst b/docs/quick_tutorial/views.rst index 15785e902..529bba0a4 100644 --- a/docs/quick_tutorial/views.rst +++ b/docs/quick_tutorial/views.rst @@ -42,7 +42,7 @@ Steps .. code-block:: bash - $ cd ..; cp -r function_testing views; cd views + $ cd ..; cp -r functional_testing views; cd views $ $VENV/bin/python setup.py develop #. Our ``views/tutorial/__init__.py`` gets a lot shorter: -- cgit v1.2.3 From 85aef4a4c0157a59bfd7ea9b3a58b842ac4de0f0 Mon Sep 17 00:00:00 2001 From: Michael Merickel Date: Tue, 8 Oct 2013 19:07:14 -0500 Subject: fix stupid missing named arguments, whyyy --- docs/tutorials/wiki2/src/authorization/tutorial/tests.py | 8 ++++---- docs/tutorials/wiki2/src/authorization/tutorial/views.py | 4 ++-- docs/tutorials/wiki2/src/tests/tutorial/tests.py | 8 ++++---- docs/tutorials/wiki2/src/tests/tutorial/views.py | 4 ++-- docs/tutorials/wiki2/src/views/tutorial/tests.py | 8 ++++---- docs/tutorials/wiki2/src/views/tutorial/views.py | 4 ++-- 6 files changed, 18 insertions(+), 18 deletions(-) diff --git a/docs/tutorials/wiki2/src/authorization/tutorial/tests.py b/docs/tutorials/wiki2/src/authorization/tutorial/tests.py index 5dcee127b..9f01d2da5 100644 --- a/docs/tutorials/wiki2/src/authorization/tutorial/tests.py +++ b/docs/tutorials/wiki2/src/authorization/tutorial/tests.py @@ -14,7 +14,7 @@ def _initTestingDB(): Base.metadata.create_all(engine) DBSession.configure(bind=engine) with transaction.manager: - model = Page('FrontPage', 'This is the front page') + model = Page(name='FrontPage', data='This is the front page') DBSession.add(model) return DBSession @@ -59,7 +59,7 @@ class ViewPageTests(unittest.TestCase): from tutorial.models import Page request = testing.DummyRequest() request.matchdict['pagename'] = 'IDoExist' - page = Page('IDoExist', 'Hello CruelWorld IDoExist') + page = Page(name='IDoExist', data='Hello CruelWorld IDoExist') self.session.add(page) _registerRoutes(self.config) info = self._callFUT(request) @@ -126,7 +126,7 @@ class EditPageTests(unittest.TestCase): _registerRoutes(self.config) request = testing.DummyRequest() request.matchdict = {'pagename':'abc'} - page = Page('abc', 'hello') + page = Page(name='abc', data='hello') self.session.add(page) info = self._callFUT(request) self.assertEqual(info['page'], page) @@ -139,7 +139,7 @@ class EditPageTests(unittest.TestCase): request = testing.DummyRequest({'form.submitted':True, 'body':'Hello yo!'}) request.matchdict = {'pagename':'abc'} - page = Page('abc', 'hello') + page = Page(name='abc', data='hello') self.session.add(page) response = self._callFUT(request) self.assertEqual(response.location, 'http://example.com/abc') diff --git a/docs/tutorials/wiki2/src/authorization/tutorial/views.py b/docs/tutorials/wiki2/src/authorization/tutorial/views.py index 0d085b0e2..b6dbbf5f6 100644 --- a/docs/tutorials/wiki2/src/authorization/tutorial/views.py +++ b/docs/tutorials/wiki2/src/authorization/tutorial/views.py @@ -63,12 +63,12 @@ def add_page(request): pagename = request.matchdict['pagename'] if 'form.submitted' in request.params: body = request.params['body'] - page = Page(pagename, body) + page = Page(name=pagename, data=body) DBSession.add(page) return HTTPFound(location = request.route_url('view_page', pagename=pagename)) save_url = request.route_url('add_page', pagename=pagename) - page = Page('', '') + page = Page(name='', data='') return dict(page=page, save_url=save_url, logged_in=authenticated_userid(request)) diff --git a/docs/tutorials/wiki2/src/tests/tutorial/tests.py b/docs/tutorials/wiki2/src/tests/tutorial/tests.py index 3e96d0a82..4ee30685e 100644 --- a/docs/tutorials/wiki2/src/tests/tutorial/tests.py +++ b/docs/tutorials/wiki2/src/tests/tutorial/tests.py @@ -15,7 +15,7 @@ def _initTestingDB(): Base.metadata.create_all(engine) DBSession.configure(bind=engine) with transaction.manager: - model = Page('FrontPage', 'This is the front page') + model = Page(name='FrontPage', data='This is the front page') DBSession.add(model) return DBSession @@ -82,7 +82,7 @@ class ViewPageTests(unittest.TestCase): from tutorial.models import Page request = testing.DummyRequest() request.matchdict['pagename'] = 'IDoExist' - page = Page('IDoExist', 'Hello CruelWorld IDoExist') + page = Page(name='IDoExist', data='Hello CruelWorld IDoExist') self.session.add(page) _registerRoutes(self.config) info = self._callFUT(request) @@ -150,7 +150,7 @@ class EditPageTests(unittest.TestCase): _registerRoutes(self.config) request = testing.DummyRequest() request.matchdict = {'pagename':'abc'} - page = Page('abc', 'hello') + page = Page(name='abc', data='hello') self.session.add(page) info = self._callFUT(request) self.assertEqual(info['page'], page) @@ -163,7 +163,7 @@ class EditPageTests(unittest.TestCase): request = testing.DummyRequest({'form.submitted':True, 'body':'Hello yo!'}) request.matchdict = {'pagename':'abc'} - page = Page('abc', 'hello') + page = Page(name='abc', data='hello') self.session.add(page) response = self._callFUT(request) self.assertEqual(response.location, 'http://example.com/abc') diff --git a/docs/tutorials/wiki2/src/tests/tutorial/views.py b/docs/tutorials/wiki2/src/tests/tutorial/views.py index 0d085b0e2..b6dbbf5f6 100644 --- a/docs/tutorials/wiki2/src/tests/tutorial/views.py +++ b/docs/tutorials/wiki2/src/tests/tutorial/views.py @@ -63,12 +63,12 @@ def add_page(request): pagename = request.matchdict['pagename'] if 'form.submitted' in request.params: body = request.params['body'] - page = Page(pagename, body) + page = Page(name=pagename, data=body) DBSession.add(page) return HTTPFound(location = request.route_url('view_page', pagename=pagename)) save_url = request.route_url('add_page', pagename=pagename) - page = Page('', '') + page = Page(name='', data='') return dict(page=page, save_url=save_url, logged_in=authenticated_userid(request)) diff --git a/docs/tutorials/wiki2/src/views/tutorial/tests.py b/docs/tutorials/wiki2/src/views/tutorial/tests.py index 5dcee127b..9f01d2da5 100644 --- a/docs/tutorials/wiki2/src/views/tutorial/tests.py +++ b/docs/tutorials/wiki2/src/views/tutorial/tests.py @@ -14,7 +14,7 @@ def _initTestingDB(): Base.metadata.create_all(engine) DBSession.configure(bind=engine) with transaction.manager: - model = Page('FrontPage', 'This is the front page') + model = Page(name='FrontPage', data='This is the front page') DBSession.add(model) return DBSession @@ -59,7 +59,7 @@ class ViewPageTests(unittest.TestCase): from tutorial.models import Page request = testing.DummyRequest() request.matchdict['pagename'] = 'IDoExist' - page = Page('IDoExist', 'Hello CruelWorld IDoExist') + page = Page(name='IDoExist', data='Hello CruelWorld IDoExist') self.session.add(page) _registerRoutes(self.config) info = self._callFUT(request) @@ -126,7 +126,7 @@ class EditPageTests(unittest.TestCase): _registerRoutes(self.config) request = testing.DummyRequest() request.matchdict = {'pagename':'abc'} - page = Page('abc', 'hello') + page = Page(name='abc', data='hello') self.session.add(page) info = self._callFUT(request) self.assertEqual(info['page'], page) @@ -139,7 +139,7 @@ class EditPageTests(unittest.TestCase): request = testing.DummyRequest({'form.submitted':True, 'body':'Hello yo!'}) request.matchdict = {'pagename':'abc'} - page = Page('abc', 'hello') + page = Page(name='abc', data='hello') self.session.add(page) response = self._callFUT(request) self.assertEqual(response.location, 'http://example.com/abc') diff --git a/docs/tutorials/wiki2/src/views/tutorial/views.py b/docs/tutorials/wiki2/src/views/tutorial/views.py index 5a9c75a61..42ef77b98 100644 --- a/docs/tutorials/wiki2/src/views/tutorial/views.py +++ b/docs/tutorials/wiki2/src/views/tutorial/views.py @@ -47,12 +47,12 @@ def add_page(request): pagename = request.matchdict['pagename'] if 'form.submitted' in request.params: body = request.params['body'] - page = Page(pagename, body) + page = Page(name=pagename, data=body) DBSession.add(page) return HTTPFound(location = request.route_url('view_page', pagename=pagename)) save_url = request.route_url('add_page', pagename=pagename) - page = Page('', '') + page = Page(name='', data='') return dict(page=page, save_url=save_url) @view_config(route_name='edit_page', renderer='templates/edit.pt') -- cgit v1.2.3 From 40d54e2aab6aae62bfdda38a0e4e7b0b4ad6857a Mon Sep 17 00:00:00 2001 From: Michael Merickel Date: Wed, 9 Oct 2013 10:55:15 -0500 Subject: add the ability to run the scripts using "python -m" for example:: env/bin/python -3 -m pyramid.scripts.pserve development.ini --- pyramid/scripts/pcreate.py | 3 ++- pyramid/scripts/pdistreport.py | 3 +++ pyramid/scripts/prequest.py | 3 +++ pyramid/scripts/proutes.py | 2 ++ pyramid/scripts/pserve.py | 3 +++ pyramid/scripts/pshell.py | 2 ++ pyramid/scripts/ptweens.py | 3 +++ pyramid/scripts/pviews.py | 2 ++ 8 files changed, 20 insertions(+), 1 deletion(-) diff --git a/pyramid/scripts/pcreate.py b/pyramid/scripts/pcreate.py index 5e2240856..9a3b53b33 100644 --- a/pyramid/scripts/pcreate.py +++ b/pyramid/scripts/pcreate.py @@ -123,4 +123,5 @@ class PCreateCommand(object): if not self.quiet: print(msg) - +if __name__ == '__main__': # pragma: no cover + sys.exit(main() or 0) diff --git a/pyramid/scripts/pdistreport.py b/pyramid/scripts/pdistreport.py index 10edb5715..61098dc27 100644 --- a/pyramid/scripts/pdistreport.py +++ b/pyramid/scripts/pdistreport.py @@ -35,3 +35,6 @@ def main(argv=sys.argv, pkg_resources=pkg_resources, platform=platform.platform, for package in packages: out(' ', package['name'], package['version']) out(' ', package['location']) + +if __name__ == '__main__': # pragma: no cover + sys.exit(main() or 0) diff --git a/pyramid/scripts/prequest.py b/pyramid/scripts/prequest.py index 8628d5a5a..2ab3b8bb9 100644 --- a/pyramid/scripts/prequest.py +++ b/pyramid/scripts/prequest.py @@ -175,3 +175,6 @@ class PRequestCommand(object): else: self.out(response.body) return 0 + +if __name__ == '__main__': # pragma: no cover + sys.exit(main() or 0) diff --git a/pyramid/scripts/proutes.py b/pyramid/scripts/proutes.py index 49e19deca..5784026bb 100644 --- a/pyramid/scripts/proutes.py +++ b/pyramid/scripts/proutes.py @@ -82,3 +82,5 @@ class PRoutesCommand(object): self.out(fmt % (route.name, pattern, view_callable)) return 0 +if __name__ == '__main__': # pragma: no cover + sys.exit(main() or 0) diff --git a/pyramid/scripts/pserve.py b/pyramid/scripts/pserve.py index 8cceecbb3..03cbc23ab 100644 --- a/pyramid/scripts/pserve.py +++ b/pyramid/scripts/pserve.py @@ -984,3 +984,6 @@ def cherrypy_server_runner( server.stop() return server + +if __name__ == '__main__': # pragma: no cover + sys.exit(main() or 0) diff --git a/pyramid/scripts/pshell.py b/pyramid/scripts/pshell.py index f74402928..dd09bf457 100644 --- a/pyramid/scripts/pshell.py +++ b/pyramid/scripts/pshell.py @@ -217,3 +217,5 @@ class PShellCommand(object): IPShell() return shell +if __name__ == '__main__': # pragma: no cover + sys.exit(main() or 0) diff --git a/pyramid/scripts/ptweens.py b/pyramid/scripts/ptweens.py index 5fe2fa120..ad52d5d8f 100644 --- a/pyramid/scripts/ptweens.py +++ b/pyramid/scripts/ptweens.py @@ -87,3 +87,6 @@ class PTweensCommand(object): self.out('') self.show_chain(tweens.implicit()) return 0 + +if __name__ == '__main__': # pragma: no cover + sys.exit(main() or 0) diff --git a/pyramid/scripts/pviews.py b/pyramid/scripts/pviews.py index 504f583b7..5e92ec4e6 100644 --- a/pyramid/scripts/pviews.py +++ b/pyramid/scripts/pviews.py @@ -248,3 +248,5 @@ class PViewsCommand(object): env['closer']() return 0 +if __name__ == '__main__': # pragma: no cover + sys.exit(main() or 0) -- cgit v1.2.3 From ba419e5b6366fae8e129e0c0e8a631b4bf508845 Mon Sep 17 00:00:00 2001 From: Michael Merickel Date: Wed, 9 Oct 2013 11:02:26 -0500 Subject: update changelog --- CHANGES.txt | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/CHANGES.txt b/CHANGES.txt index 6e73de823..a228fbb3a 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,6 +1,15 @@ Unreleased ========== +Features +-------- + +- Pyramid's console scripts (``pserve``, ``pviews``, etc) can now be run + directly, allowing custom arguments to be sent to the python interpreter + at runtime. For example:: + + python -3 -m pyramid.scripts.pserve development.ini + Bug Fixes --------- -- cgit v1.2.3 From bd3d23330abfe39182b7c47f79f61f26e20d1221 Mon Sep 17 00:00:00 2001 From: Paul Everitt Date: Wed, 9 Oct 2013 13:53:10 -0400 Subject: Hedge a little while the compendium of session add-ons is written. --- docs/quick_tutorial/sessions.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/quick_tutorial/sessions.rst b/docs/quick_tutorial/sessions.rst index ba26d0133..0f284e9a7 100644 --- a/docs/quick_tutorial/sessions.rst +++ b/docs/quick_tutorial/sessions.rst @@ -13,8 +13,8 @@ When people use your web application, they frequently perform a task that requires semi-permanent data to be saved. For example, a shopping cart. This is called a :term:`session`. -Pyramid has basic built-in support for sessions, with add-ons such as -*dogpile.cache* (or your own custom sessioning engine) that provide +Pyramid has basic built-in support for sessions, with add-ons +or your own custom sessioning engine) that can provide richer session support. Let's take a look at the :ref:`built-in sessioning support `. -- cgit v1.2.3 From 41ce5c5ce42288d7a4ad26e405c4681530379e35 Mon Sep 17 00:00:00 2001 From: Tshepang Lekhonkhobe Date: Fri, 11 Oct 2013 22:54:23 +0200 Subject: docs: rm redundancy --- HACKING.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/HACKING.txt b/HACKING.txt index be67000ce..eab3889ca 100644 --- a/HACKING.txt +++ b/HACKING.txt @@ -27,8 +27,7 @@ By Hand Note that very old versions of virtualenv (virtualenv versions below, say, 1.10 or thereabouts) require you to pass a ``--no-site-packages`` flag to - get a completely isolated environment. If you're on an old system, use - ``virtualenv --no-site-packages`` instead of ``virtualenv`` above. + get a completely isolated environment. You can choose which Python version you want to use by passing a ``-p`` flag to ``virtualenv``. For example, ``virtualenv -ppython2.7`` -- cgit v1.2.3 From d53fd254ccb82b17b590fb236ce9671c8a80c567 Mon Sep 17 00:00:00 2001 From: Tshepang Lekhonkhobe Date: Fri, 11 Oct 2013 22:55:07 +0200 Subject: docs: capitalise --- HACKING.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/HACKING.txt b/HACKING.txt index eab3889ca..683ac61f5 100644 --- a/HACKING.txt +++ b/HACKING.txt @@ -81,7 +81,7 @@ way to get going. (alternately, create a writeable fork on GitHub and check that out). -Since pyramid is a framework and not an application, it can be +Since Pyramid is a framework and not an application, it can be convenient to work against a sample application, preferably in its own virtualenv. A quick way to achieve this is to (ab-)use ``tox`` (http://tox.readthedocs.org/en/latest/) with a custom configuration @@ -89,7 +89,7 @@ file that's part of the checkout:: tox -c hacking-tox.ini -This will create a python-2.7 based virtualenv named ``env27`` (pyramid's +This will create a python-2.7 based virtualenv named ``env27`` (Pyramid's ``.gitconfig` ignores all top-level folders that start with ``env`` specifically for this use case) and inside that a simple pyramid application named ``hacking`` that you can then fire up like so:: -- cgit v1.2.3 From e7ad85361379bc0d8276a2583ae20ac84b3989c8 Mon Sep 17 00:00:00 2001 From: Tshepang Lekhonkhobe Date: Fri, 11 Oct 2013 22:55:17 +0200 Subject: docs: typos --- HACKING.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/HACKING.txt b/HACKING.txt index 683ac61f5..b32a8a957 100644 --- a/HACKING.txt +++ b/HACKING.txt @@ -165,7 +165,7 @@ Running Tests $ cd ~/hack-on-pyramid/ $ /usr/bin/tox -- The tests can also be run usign ``pytest`` (http://pytest.org/). This is +- The tests can also be run using ``pytest`` (http://pytest.org/). This is intended as a convenience for people who are more used or fond of ``pytest``. Run the tests like so:: @@ -191,7 +191,7 @@ or adds the feature. To build and review docs (where ``$VENV`` refers to the virtualenv you're using to develop Pyramid): -1. After follwing the steps above in "Using a Development Checkout", cause +1. After following the steps above in "Using a Development Checkout", cause Sphinx and all development requirements to be installed in your virtualenv:: -- cgit v1.2.3 From 6db4eb3a5fe625918c52b40ed669f1b55343abf9 Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Mon, 14 Oct 2013 12:42:17 +0200 Subject: add note about custom args to python when using command-line scripts --- docs/narr/commandline.rst | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/docs/narr/commandline.rst b/docs/narr/commandline.rst index 58b9bdd21..0984b4daf 100644 --- a/docs/narr/commandline.rst +++ b/docs/narr/commandline.rst @@ -474,6 +474,17 @@ input of the ``prequest`` process is used as the ``POST`` body:: $ $VENV/bin/prequest -mPOST development.ini / < somefile +Using Custom Arguments to Python when Running ``p*`` Scripts +------------------------------------------------------------ + +.. versionadded:: 1.5 + +Each of Pyramid's console scripts (``pserve``, ``pviews``, etc) can be run +directly using ``python -m``, allowing custom arguments to be sent to the +python interpreter at runtime. For example:: + + python -3 -m pyramid.scripts.pserve development.ini + Showing All Installed Distributions and their Versions ------------------------------------------------------ -- cgit v1.2.3 From b474e206c38f417439f994f83637420eb196617e Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Mon, 14 Oct 2013 16:05:50 +0200 Subject: make these tests pass on python 3.2+ --- docs/tutorials/wiki/src/tests/tutorial/tests.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/docs/tutorials/wiki/src/tests/tutorial/tests.py b/docs/tutorials/wiki/src/tests/tutorial/tests.py index c435a4519..5add04c20 100644 --- a/docs/tutorials/wiki/src/tests/tutorial/tests.py +++ b/docs/tutorials/wiki/src/tests/tutorial/tests.py @@ -158,11 +158,11 @@ class FunctionalTests(unittest.TestCase): def test_FrontPage(self): res = self.testapp.get('/FrontPage', status=200) - self.assertTrue('FrontPage' in res.body) + self.assertTrue(b'FrontPage' in res.body) def test_unexisting_page(self): res = self.testapp.get('/SomePage', status=404) - self.assertTrue('Not Found' in res.body) + self.assertTrue(b'Not Found' in res.body) def test_successful_log_in(self): res = self.testapp.get( self.viewer_login, status=302) @@ -170,48 +170,48 @@ class FunctionalTests(unittest.TestCase): def test_failed_log_in(self): res = self.testapp.get( self.viewer_wrong_login, status=200) - self.assertTrue('login' in res.body) + self.assertTrue(b'login' in res.body) def test_logout_link_present_when_logged_in(self): res = self.testapp.get( self.viewer_login, status=302) res = self.testapp.get('/FrontPage', status=200) - self.assertTrue('Logout' in res.body) + self.assertTrue(b'Logout' in res.body) def test_logout_link_not_present_after_logged_out(self): res = self.testapp.get( self.viewer_login, status=302) res = self.testapp.get('/FrontPage', status=200) res = self.testapp.get('/logout', status=302) - self.assertTrue('Logout' not in res.body) + self.assertTrue(b'Logout' not in res.body) def test_anonymous_user_cannot_edit(self): res = self.testapp.get('/FrontPage/edit_page', status=200) - self.assertTrue('Login' in res.body) + self.assertTrue(b'Login' in res.body) def test_anonymous_user_cannot_add(self): res = self.testapp.get('/add_page/NewPage', status=200) - self.assertTrue('Login' in res.body) + self.assertTrue(b'Login' in res.body) def test_viewer_user_cannot_edit(self): res = self.testapp.get( self.viewer_login, status=302) res = self.testapp.get('/FrontPage/edit_page', status=200) - self.assertTrue('Login' in res.body) + self.assertTrue(b'Login' in res.body) def test_viewer_user_cannot_add(self): res = self.testapp.get( self.viewer_login, status=302) res = self.testapp.get('/add_page/NewPage', status=200) - self.assertTrue('Login' in res.body) + self.assertTrue(b'Login' in res.body) def test_editors_member_user_can_edit(self): res = self.testapp.get( self.editor_login, status=302) res = self.testapp.get('/FrontPage/edit_page', status=200) - self.assertTrue('Editing' in res.body) + self.assertTrue(b'Editing' in res.body) def test_editors_member_user_can_add(self): res = self.testapp.get( self.editor_login, status=302) res = self.testapp.get('/add_page/NewPage', status=200) - self.assertTrue('Editing' in res.body) + self.assertTrue(b'Editing' in res.body) def test_editors_member_user_can_view(self): res = self.testapp.get( self.editor_login, status=302) res = self.testapp.get('/FrontPage', status=200) - self.assertTrue('FrontPage' in res.body) + self.assertTrue(b'FrontPage' in res.body) -- cgit v1.2.3 From a10a8f56d0c4efc232e3138e5d97eff06efd52d1 Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Mon, 14 Oct 2013 16:35:45 +0200 Subject: temporarily dont run tests to see impact on readthedocs --- docs/conf.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index ec62faa99..490df48cc 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -150,16 +150,16 @@ if 'sphinx-build' in ' '.join(sys.argv): # protect against dumb importers sys.path.append(os.path.abspath('_themes')) - parent = os.path.dirname(os.path.dirname(__file__)) - sys.path.append(os.path.abspath(parent)) - wd = os.getcwd() - os.chdir(parent) - os.system('%s setup.py test -q' % sys.executable) - os.chdir(wd) - - for item in os.listdir(parent): - if item.endswith('.egg'): - sys.path.append(os.path.join(parent, item)) + # parent = os.path.dirname(os.path.dirname(__file__)) + # sys.path.append(os.path.abspath(parent)) + # wd = os.getcwd() + # os.chdir(parent) + # os.system('%s setup.py test -q' % sys.executable) + # os.chdir(wd) + + # for item in os.listdir(parent): + # if item.endswith('.egg'): + # sys.path.append(os.path.join(parent, item)) html_theme_path = ['_themes'] html_theme = 'pyramid' -- cgit v1.2.3 From 48afc25e990eb875c8e605498b13876bffce417d Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Mon, 14 Oct 2013 16:50:50 +0200 Subject: Address #866; don't run the tests when the docs build, this means that 'make html' must be run using a SPHINXBUILD=/path/to/virtualenv/with/pyramid --- docs/conf.py | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index 490df48cc..a447c9968 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -150,17 +150,6 @@ if 'sphinx-build' in ' '.join(sys.argv): # protect against dumb importers sys.path.append(os.path.abspath('_themes')) - # parent = os.path.dirname(os.path.dirname(__file__)) - # sys.path.append(os.path.abspath(parent)) - # wd = os.getcwd() - # os.chdir(parent) - # os.system('%s setup.py test -q' % sys.executable) - # os.chdir(wd) - - # for item in os.listdir(parent): - # if item.endswith('.egg'): - # sys.path.append(os.path.join(parent, item)) - html_theme_path = ['_themes'] html_theme = 'pyramid' html_theme_options = dict( -- cgit v1.2.3 From 3acee31f86bcde8abbb4e63715afc5ca67976eaf Mon Sep 17 00:00:00 2001 From: Michael Merickel Date: Thu, 17 Oct 2013 13:32:49 -0500 Subject: fix documentation for csrf checking --- docs/narr/sessions.rst | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/docs/narr/sessions.rst b/docs/narr/sessions.rst index 649d22bd2..f33bc6132 100644 --- a/docs/narr/sessions.rst +++ b/docs/narr/sessions.rst @@ -363,25 +363,27 @@ Or, include it as a header in a jQuery AJAX request: The handler for the URL that receives the request should then require that the correct CSRF token is supplied. -Using the ``session.check_csrf_token`` Method -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Checking CSRF Tokens Manually +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In request handling code, you can check the presence and validity of a CSRF -token with ``session.check_csrf_token(request)``. If the token is valid, -it will return True, otherwise it will raise ``HTTPBadRequest``. +token with :func:`pyramid.session.check_csrf_token(request)``. If the token is +valid, it will return ``True``, otherwise it will raise ``HTTPBadRequest``. +Optionally, you can specify ``raises=False`` to have the check return ``False`` +instead of raising an exception. By default, it checks for a GET or POST parameter named ``csrf_token`` or a header named ``X-CSRF-Token``. .. code-block:: python - def myview(request): - session = request.session + from pyramid.session import check_csrf_token + def myview(request): # Require CSRF Token - session.check_csrf_token(request): + check_csrf_token(request) - ... + # ... .. index:: single: session.new_csrf_token -- cgit v1.2.3