From 773a370c590ed82c143aa548f55ab9472601449b Mon Sep 17 00:00:00 2001 From: Michael Merickel Date: Tue, 19 Apr 2011 02:50:27 -0500 Subject: Upgraded the url dispatch tutorials to use add_view. --- docs/tutorials/wiki2/basiclayout.rst | 37 ++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) (limited to 'docs/tutorials/wiki2/basiclayout.rst') diff --git a/docs/tutorials/wiki2/basiclayout.rst b/docs/tutorials/wiki2/basiclayout.rst index 0dbcf6684..bb39a686d 100644 --- a/docs/tutorials/wiki2/basiclayout.rst +++ b/docs/tutorials/wiki2/basiclayout.rst @@ -81,28 +81,33 @@ via the :meth:`pyramid.config.Configurator.add_route` method that will be used when the URL is ``/``: .. literalinclude:: src/basiclayout/tutorial/__init__.py - :lines: 13-14 + :lines: 13 :language: py Since this route has a ``pattern`` equalling ``/`` it is the route that will -be called when the URL ``/`` is visted, e.g. ``http://localhost:6543/``. The -argument named ``view`` with the value ``tutorial.views.my_view`` is the -dotted name to a *function* we write (generated by the -``pyramid_routesalchemy`` scaffold) that is given a ``request`` object and -which returns a response or a dictionary. - -You will use :meth:`pyramid.config.Configurator.add_route` statements in a -:term:`URL dispatch` based application to map URLs to code. This route also -names a ``view_renderer``, which is a template which lives in the -``templates`` subdirectory of the package. When the -``tutorial.views.my_view`` view returns a dictionary, a :term:`renderer` will -use this template to create a response. - -Fimnally, we use the :meth:`pyramid.config.Configurator.make_wsgi_app` +be called when the URL ``/`` is visted, e.g. ``http://localhost:6543/``. + +Mapping the ``home`` route to code is done by registering a ``view``. You will +use :meth:`pyramid.config.Configurator.add_view` in :term:`URL dispatch` to +register views for the routes, mapping your patterns to code: + + .. literalinclude:: src/basiclayout/tutorial/__init__.py + :lines: 14 + :language: py + +The ``view`` argument of ``tutorial.views.my_view`` is the dotted name to a +*function* we write (generated by the ``pyramid_routesalchemy`` scaffold) that +is given a ``request`` object and which returns a response or a dictionary. +This view also names a ``renderer``, which is a template which lives in the +``templates`` subdirectory of the package. When the ``tutorial.views.my_view`` +view returns a dictionary, a :term:`renderer` will use this template to create +a response. + +Finally, we use the :meth:`pyramid.config.Configurator.make_wsgi_app` method to return a :term:`WSGI` application: .. literalinclude:: src/basiclayout/tutorial/__init__.py - :lines: 15 + :lines: 16 :language: py Our final ``__init__.py`` file will look like this: -- cgit v1.2.3 From ed7ffe0e2065100f551793b3774656d8bdde0fb0 Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Fri, 22 Apr 2011 13:42:19 -0400 Subject: - Make sure deprecation warnings aren't raised when tests are run. - Modify documentation for cross-referencing. - Use add_view(viewname) syntax rather than add_view(view=viewname) syntax for normalization. - Use warnings.warn rather than zope.deprecated in order to make testing easier. - Move tests which test deprecated methods of configurator to a separate test case. --- docs/tutorials/wiki2/basiclayout.rst | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'docs/tutorials/wiki2/basiclayout.rst') diff --git a/docs/tutorials/wiki2/basiclayout.rst b/docs/tutorials/wiki2/basiclayout.rst index bb39a686d..82e112c64 100644 --- a/docs/tutorials/wiki2/basiclayout.rst +++ b/docs/tutorials/wiki2/basiclayout.rst @@ -85,9 +85,9 @@ used when the URL is ``/``: :language: py Since this route has a ``pattern`` equalling ``/`` it is the route that will -be called when the URL ``/`` is visted, e.g. ``http://localhost:6543/``. +be matched when the URL ``/`` is visted, e.g. ``http://localhost:6543/``. -Mapping the ``home`` route to code is done by registering a ``view``. You will +Mapping the ``home`` route to code is done by registering a view. You will use :meth:`pyramid.config.Configurator.add_view` in :term:`URL dispatch` to register views for the routes, mapping your patterns to code: @@ -95,13 +95,14 @@ register views for the routes, mapping your patterns to code: :lines: 14 :language: py -The ``view`` argument of ``tutorial.views.my_view`` is the dotted name to a -*function* we write (generated by the ``pyramid_routesalchemy`` scaffold) that -is given a ``request`` object and which returns a response or a dictionary. -This view also names a ``renderer``, which is a template which lives in the -``templates`` subdirectory of the package. When the ``tutorial.views.my_view`` -view returns a dictionary, a :term:`renderer` will use this template to create -a response. +The first positional ``add_view`` argument ``tutorial.views.my_view`` is the +dotted name to a *function* we write (generated by the +``pyramid_routesalchemy`` scaffold) that is given a ``request`` object and +which returns a response or a dictionary. This view also names a +``renderer``, which is a template which lives in the ``templates`` +subdirectory of the package. When the ``tutorial.views.my_view`` view +returns a dictionary, a :term:`renderer` will use this template to create a +response. This Finally, we use the :meth:`pyramid.config.Configurator.make_wsgi_app` method to return a :term:`WSGI` application: -- cgit v1.2.3