From 1aa978c074afce7f821634e5aa8366caa07ee437 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20B=C3=BCchler?= Date: Wed, 23 May 2012 09:28:53 +0300 Subject: Fixed a few glitches in the "Using a Route Prefix to Compose Applications" section of the docs/narr/urldispatch.rst docs. --- docs/narr/urldispatch.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/narr/urldispatch.rst b/docs/narr/urldispatch.rst index acbccbdfd..ecf3d026a 100644 --- a/docs/narr/urldispatch.rst +++ b/docs/narr/urldispatch.rst @@ -954,7 +954,7 @@ will be prepended with the first: from pyramid.config import Configurator def timing_include(config): - config.add_route('show_times', /times') + config.add_route('show_times', '/times') def users_include(config): config.add_route('show_users', '/show') @@ -966,7 +966,7 @@ will be prepended with the first: In the above configuration, the ``show_users`` route will still have an effective route pattern of ``/users/show``. The ``show_times`` route -however, will have an effective pattern of ``/users/timing/show_times``. +however, will have an effective pattern of ``/users/timing/times``. Route prefixes have no impact on the requirement that the set of route *names* in any given Pyramid configuration must be entirely unique. If you @@ -981,7 +981,7 @@ that may be added in the future. For example: from pyramid.config import Configurator def timing_include(config): - config.add_route('timing.show_times', /times') + config.add_route('timing.show_times', '/times') def users_include(config): config.add_route('users.show_users', '/show') -- cgit v1.2.3 From 566a2a641a03b2d4bec6b19e8d20148dbc2769b4 Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Mon, 4 Jun 2012 19:19:24 -0400 Subject: point back to renderer_system_values in render and render_to_response --- pyramid/renderers.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/pyramid/renderers.py b/pyramid/renderers.py index c5d33dc16..e526f9997 100644 --- a/pyramid/renderers.py +++ b/pyramid/renderers.py @@ -65,10 +65,11 @@ def render(renderer_name, value, request=None, package=None): dictionary. For other renderers, this will need to be whatever sort of value the renderer expects. - The 'system' values supplied to the renderer will include a basic - set of top-level system names, such as ``request``, ``context``, - and ``renderer_name``. If :term:`renderer globals` have been - specified, these will also be used to agument the value. + The 'system' values supplied to the renderer will include a basic set of + top-level system names, such as ``request``, ``context``, + ``renderer_name``, and ``view``. See :ref:`renderer_system_values` for + the full list. If :term:`renderer globals` have been specified, these + will also be used to agument the value. Supply a ``request`` parameter in order to provide the renderer with the most correct 'system' values (``request`` and ``context`` @@ -108,10 +109,11 @@ def render_to_response(renderer_name, value, request=None, package=None): dictionary. For other renderers, this will need to be whatever sort of value the renderer expects. - The 'system' values supplied to the renderer will include a basic - set of top-level system names, such as ``request``, ``context``, - and ``renderer_name``. If :term:`renderer globals` have been - specified, these will also be used to agument the value. + The 'system' values supplied to the renderer will include a basic set of + top-level system names, such as ``request``, ``context``, + ``renderer_name``, and ``view``. See :ref:`renderer_system_values` for + the full list. If :term:`renderer globals` have been specified, these + will also be used to agument the value. Supply a ``request`` parameter in order to provide the renderer with the most correct 'system' values (``request`` and ``context`` -- cgit v1.2.3 From a319249fdb6e0539e65e0b297829ed8c7f799b98 Mon Sep 17 00:00:00 2001 From: Jeff Cook Date: Thu, 7 Jun 2012 14:00:07 -0600 Subject: Update documentation to clarify purpose of BeforeRender.rendering_val. --- docs/narr/hooks.rst | 15 +++++++++++++++ pyramid/events.py | 20 ++++++++++++++++---- 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/docs/narr/hooks.rst b/docs/narr/hooks.rst index a2143b3c5..30eec04f0 100644 --- a/docs/narr/hooks.rst +++ b/docs/narr/hooks.rst @@ -289,6 +289,21 @@ keys added to the renderer globals dictionary by all :class:`pyramid.events.BeforeRender` subscribers and renderer globals factories must be unique. +The dictionary returned from the view is accessible through the +:attr:`rendering_val` attribute of a :class:`~pyramid.events.BeforeRender` +event, like so: + +.. code-block:: python + :linenos: + + from pyramid.events import subscriber + from pyramid.events import BeforeRender + + @subscriber(BeforeRender) + def read_return(event): + # 'mykey' is returned from the view + print(event.rendering_val['mykey']) + See the API documentation for the :class:`~pyramid.events.BeforeRender` event interface at :class:`pyramid.interfaces.IBeforeRender`. diff --git a/pyramid/events.py b/pyramid/events.py index e181ef33f..1941c594c 100644 --- a/pyramid/events.py +++ b/pyramid/events.py @@ -200,10 +200,22 @@ class BeforeRender(dict): setting an overriding value (which can be done using ``.get`` or ``__contains__`` of the event object). - The event has an additional attribute named ``rendering_val``. This is - the (non-system) value returned by a view or passed to ``render*`` as - ``value``. This feature is new in Pyramid 1.2. - + The dictionary returned from the view is accessible through the + :attr:`rendering_val` attribute of a :class:`~pyramid.events.BeforeRender` + event, like so:: + + from pyramid.events import subscriber + from pyramid.events import BeforeRender + + @subscriber(BeforeRender) + def read_return(event): + # "mykey" is returned from the view + print(event.rendering_val['mykey']) + + In other words, ``rendering_val`` is the (non-system) value returned by a + view or passed to ``render*`` as ``value``. This feature is new in Pyramid + 1.2. + For a description of the values present in the renderer globals dictionary, see :ref:`renderer_system_values`. -- cgit v1.2.3 From dcab614e3252054eba5f2333af8bc3c4120e9980 Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Thu, 7 Jun 2012 18:21:13 -0400 Subject: rendering --- pyramid/url.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyramid/url.py b/pyramid/url.py index dd83bb631..52e172d3f 100644 --- a/pyramid/url.py +++ b/pyramid/url.py @@ -711,7 +711,7 @@ class URLMethodsMixin(object): _app_url=request.script_name)``. :meth:`pyramid.request.Request.current_route_path` is, in fact, implemented in terms of - `:meth:`pyramid.request.Request.current_route_url` in just this + :meth:`pyramid.request.Request.current_route_url` in just this way. As a result, any ``_app_url`` passed within the ``**kw`` values to ``current_route_path`` will be ignored. """ -- cgit v1.2.3 From 8c4210f94132e2ba844732bd1dada82696fc20db Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Mon, 11 Jun 2012 11:03:56 -0400 Subject: how to build HTML docs --- HACKING.txt | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/HACKING.txt b/HACKING.txt index 593e89ac1..ec0bcb000 100644 --- a/HACKING.txt +++ b/HACKING.txt @@ -48,6 +48,23 @@ checkout. $ cd starter $ ../bin/python setup.py develop +Building the HTML Docs +----------------------- + +- Check out Pyramid from Github. + +- Create a virtualenv or reuse an existing one that you're using to develop + Pyramid. + +- Run ``$yourvenv/bin/python setup.py dev docs``. + +- cd to ``docs`` within the Pyramid checkout and execute ``make clean html + SPHINXBUILD=$yourvenv/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. + +- The rendered HTML docs will end up in ``docs/_build/html``. + Adding Features --------------- -- cgit v1.2.3 From c7fcdf1665cfdc1173559baa0a56d9a06fcba448 Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Mon, 11 Jun 2012 11:16:07 -0400 Subject: consolidate --- HACKING.txt | 46 +++++++++++++++++----------------------------- 1 file changed, 17 insertions(+), 29 deletions(-) diff --git a/HACKING.txt b/HACKING.txt index ec0bcb000..dd735bf22 100644 --- a/HACKING.txt +++ b/HACKING.txt @@ -48,23 +48,6 @@ checkout. $ cd starter $ ../bin/python setup.py develop -Building the HTML Docs ------------------------ - -- Check out Pyramid from Github. - -- Create a virtualenv or reuse an existing one that you're using to develop - Pyramid. - -- Run ``$yourvenv/bin/python setup.py dev docs``. - -- cd to ``docs`` within the Pyramid checkout and execute ``make clean html - SPHINXBUILD=$yourvenv/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. - -- The rendered HTML docs will end up in ``docs/_build/html``. - Adding Features --------------- @@ -130,23 +113,28 @@ Test Coverage ``nose`` and ``coverage`` into your virtualenv, and running ``setup.py nosetests --with-coverage``. -Documentation Coverage ----------------------- +Documentation Coverage and Building HTML Documentation +------------------------------------------------------ -- If you fix a bug, and the bug requires an API or behavior - modification, all documentation in this package which references - that API or behavior must change to reflect the bug fix, ideally in - the same commit that fixes the bug or adds the feature. +If you fix a bug, and the bug requires an API or behavior modification, all +documentation in this package which references that API or behavior must +change to reflect the bug fix, ideally in the same commit that fixes the bug +or adds the feature. -- To build and review docs: +To build and review docs (where ``$yourvenv`` refers to the virtualenv you're +using to develop Pyramid): - 1. Install ``tests_require`` dependencies from Pyramid's setup.py into your - virtualenv. +1. Run ``$yourvenv/bin/python setup.py dev docs``. This will cause Sphinx + and all development requirements to be installed in your virtualenv. - 2. From the ``docs`` directory of the Pyramid checkout run ``make html - SPHINXBUILD=/path/to/your/virtualenv/bin/sphinx-build``. +2. cd to the ``docs`` directory within your Pyramid checkout and execute + ``make clean html SPHINXBUILD=$yourvenv/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. - 3. Open the _build/html/index.html file to see the resulting rendering. +3. Open the ``docs/_build/html/index.html`` file to see the resulting HTML + rendering. Change Log ---------- -- cgit v1.2.3 From 0487d5e05dd61d6d7482212d40fb5884e06f582a Mon Sep 17 00:00:00 2001 From: Michael Merickel Date: Tue, 12 Jun 2012 11:18:37 -0500 Subject: docs reference setup_logging instead of fileConfig --- docs/narr/commandline.rst | 7 +++++-- docs/narr/logging.rst | 7 ++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/docs/narr/commandline.rst b/docs/narr/commandline.rst index 4be436836..af53c1f78 100644 --- a/docs/narr/commandline.rst +++ b/docs/narr/commandline.rst @@ -654,8 +654,11 @@ use the following command: .. code-block:: python - import logging.config - logging.config.fileConfig('/path/to/my/development.ini') + import pyramid.paster + pyramid.paster.setup_logging('/path/to/my/development.ini') + +See :ref:`logging_chapter` for more information on logging within +:app:`Pyramid`. .. index:: single: console script diff --git a/docs/narr/logging.rst b/docs/narr/logging.rst index 044655c1f..f4c38abb6 100644 --- a/docs/narr/logging.rst +++ b/docs/narr/logging.rst @@ -14,7 +14,7 @@ how to send log messages to loggers that you've configured. which help configure logging. All of the scaffolds which ship along with :app:`Pyramid` do this. If you're not using a scaffold, or if you've used a third-party scaffold which does not create these files, the - configuration information in this chapter will not be applicable. + configuration information in this chapter may not be applicable. .. _logging_config: @@ -36,10 +36,11 @@ application-related and logging-related sections in the configuration file can coexist peacefully, and the logging-related sections in the file are used from when you run ``pserve``. -The ``pserve`` command calls the `logging.fileConfig function +The ``pserve`` command calls the :func:`pyramid.paster.setup_logging` +function, a thin wrapper around the `logging.fileConfig `_ using the specified ini file if it contains a ``[loggers]`` section (all of the -scaffold-generated ``.ini`` files do). ``logging.fileConfig`` reads the +scaffold-generated ``.ini`` files do). ``setup_logging`` reads the logging configuration from the ini file upon which ``pserve`` was invoked. -- cgit v1.2.3 From b555e98c477056a7b32a46294c42c11a3b96b432 Mon Sep 17 00:00:00 2001 From: Marc Abramowitz Date: Fri, 1 Jun 2012 07:56:13 -0700 Subject: Add "py33" to tox.ini --- tox.ini | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index 97aa6c4d0..85bd41bda 100644 --- a/tox.ini +++ b/tox.ini @@ -1,6 +1,6 @@ [tox] envlist = - py26,py27,py32,pypy,cover + py26,py27,py32,py33,pypy,cover [testenv] commands = @@ -21,6 +21,14 @@ deps = virtualenv venusian +[testenv:py33] +commands = + python setup.py test -q +deps = + WebTest + virtualenv + venusian + [testenv:cover] basepython = python2.6 -- cgit v1.2.3 From 366f9d5960c0cb85ef0ab9403e37e19fc85961d0 Mon Sep 17 00:00:00 2001 From: Marc Abramowitz Date: Fri, 1 Jun 2012 07:59:11 -0700 Subject: Add .travis.yml for Travis CI (http://travis-ci.org/) --- .travis.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 000000000..cb4cc69e1 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,14 @@ +language: python + +python: + - 2.6 + - 2.7 + - pypy + - 3.2 + +matrix: + allow_failures: + - python: pypy + +script: python setup.py test + -- cgit v1.2.3 From b5478966861d3de23ca299c26891f9709cf09ad7 Mon Sep 17 00:00:00 2001 From: Marc Abramowitz Date: Wed, 13 Jun 2012 08:06:15 -0700 Subject: Add "Marc Abramowitz" to CONTRIBUTORS.txt --- CONTRIBUTORS.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CONTRIBUTORS.txt b/CONTRIBUTORS.txt index 98f73d5f9..027fc0857 100644 --- a/CONTRIBUTORS.txt +++ b/CONTRIBUTORS.txt @@ -172,3 +172,5 @@ Contributors - Wayne Witzel III, 2012/03/27 - Marin Rukavina, 2012/05/03 + +- Marc Abramowitz, 2012/06/13 -- cgit v1.2.3 From e07b4f8edd32766dd0c8327d04a9c7b99d8dc2e9 Mon Sep 17 00:00:00 2001 From: Marc Abramowitz Date: Thu, 14 Jun 2012 17:27:28 -0700 Subject: Remove blank line from .travis.yml --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index cb4cc69e1..2e737af04 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,4 +11,3 @@ matrix: - python: pypy script: python setup.py test - -- cgit v1.2.3 From 2516df30d73afdf6606ad3d89b7c24ab496f356d Mon Sep 17 00:00:00 2001 From: Jeff Cook Date: Sun, 17 Jun 2012 01:20:37 -0600 Subject: docs: Add view callable example to section on rendering_val. --- docs/narr/hooks.rst | 31 +++++++++++++++++++++++-------- pyramid/events.py | 18 +++++++++++++++--- 2 files changed, 38 insertions(+), 11 deletions(-) diff --git a/docs/narr/hooks.rst b/docs/narr/hooks.rst index 30eec04f0..332805152 100644 --- a/docs/narr/hooks.rst +++ b/docs/narr/hooks.rst @@ -291,18 +291,33 @@ factories must be unique. The dictionary returned from the view is accessible through the :attr:`rendering_val` attribute of a :class:`~pyramid.events.BeforeRender` -event, like so: +event. + +Suppose you return ``{'mykey': 'somevalue', 'mykey2': 'somevalue2'}`` from +your view callable, like so: .. code-block:: python - :linenos: + :linenos: - from pyramid.events import subscriber - from pyramid.events import BeforeRender + from pyramid.view import view_config - @subscriber(BeforeRender) - def read_return(event): - # 'mykey' is returned from the view - print(event.rendering_val['mykey']) + @view_config(renderer='some_renderer') + def myview(request): + return {'mykey': 'somevalue', 'mykey2': 'somevalue2'} + +:attr:`rendering_val` can be used to access these values from the +:class:`~pyramid.events.BeforeRender` object: + +.. code-block:: python + :linenos: + + from pyramid.events import subscriber + from pyramid.events import BeforeRender + + @subscriber(BeforeRender) + def read_return(event): + # {'mykey': 'somevalue'} is returned from the view + print(event.rendering_val['mykey']) See the API documentation for the :class:`~pyramid.events.BeforeRender` event interface at :class:`pyramid.interfaces.IBeforeRender`. diff --git a/pyramid/events.py b/pyramid/events.py index 1941c594c..db274823c 100644 --- a/pyramid/events.py +++ b/pyramid/events.py @@ -202,17 +202,29 @@ class BeforeRender(dict): The dictionary returned from the view is accessible through the :attr:`rendering_val` attribute of a :class:`~pyramid.events.BeforeRender` - event, like so:: + event. + + Suppose you return ``{'mykey': 'somevalue', 'mykey2': 'somevalue2'}`` from + your view callable, like so:: + + from pyramid.view import view_config + + @view_config(renderer='some_renderer') + def myview(request): + return {'mykey': 'somevalue', 'mykey2': 'somevalue2'} + + :attr:`rendering_val` can be used to access these values from the + :class:`~pyramid.events.BeforeRender` object:: from pyramid.events import subscriber from pyramid.events import BeforeRender @subscriber(BeforeRender) def read_return(event): - # "mykey" is returned from the view + # {'mykey': 'somevalue'} is returned from the view print(event.rendering_val['mykey']) - In other words, ``rendering_val`` is the (non-system) value returned by a + In other words, :attr:`rendering_val` is the (non-system) value returned by a view or passed to ``render*`` as ``value``. This feature is new in Pyramid 1.2. -- cgit v1.2.3 From 4761ec79e1f3e0daeb4ba8351c27eb2a715f07a4 Mon Sep 17 00:00:00 2001 From: Jeff Cook Date: Sun, 17 Jun 2012 01:24:20 -0600 Subject: CONTRIBUTORS: Add self / accept contribution terms --- CONTRIBUTORS.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CONTRIBUTORS.txt b/CONTRIBUTORS.txt index 98f73d5f9..2baeea3dc 100644 --- a/CONTRIBUTORS.txt +++ b/CONTRIBUTORS.txt @@ -172,3 +172,5 @@ Contributors - Wayne Witzel III, 2012/03/27 - Marin Rukavina, 2012/05/03 + +- Jeff Cook, 2012/06/16 -- cgit v1.2.3