summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorChris McDonough <chrism@agendaless.com>2009-06-24 19:41:09 +0000
committerChris McDonough <chrism@agendaless.com>2009-06-24 19:41:09 +0000
commitea18a50b5e38afdc01748473036988be5289718a (patch)
treea5d25e0fcc9054dbf0b816c3a7c2b13e594794c6 /docs
parent05c02322f5a09c14f49c529d6fd885153e52c66f (diff)
downloadpyramid-ea18a50b5e38afdc01748473036988be5289718a.tar.gz
pyramid-ea18a50b5e38afdc01748473036988be5289718a.tar.bz2
pyramid-ea18a50b5e38afdc01748473036988be5289718a.zip
- ``repoze.bfg`` no longer relies on the Routes package to interpret
URL paths.
Diffstat (limited to 'docs')
-rw-r--r--docs/glossary.rst17
-rw-r--r--docs/narr/project.rst8
-rw-r--r--docs/narr/router.rst22
-rw-r--r--docs/narr/urldispatch.rst115
-rw-r--r--docs/narr/urlmapping.rst15
-rw-r--r--docs/tutorials/bfgwiki2/installation.rst2
6 files changed, 48 insertions, 131 deletions
diff --git a/docs/glossary.rst b/docs/glossary.rst
index 217c70098..7382a389e 100644
--- a/docs/glossary.rst
+++ b/docs/glossary.rst
@@ -84,11 +84,13 @@ Glossary
returns responses to the WSGI server on behalf of your
:mod:`repoze.bfg` application.
URL dispatch
+
An alternative to graph traversal as a mechanism for locating a
- :term:`context` for a :term:`view`. When you use :term:`Routes`
+ :term:`context` for a :term:`view`. When you use a :term:`route`
in your :mod:`repoze.bfg` application via a ``<route>``
declaration in ZCML, you are using URL dispatch. See the
:ref:`urldispatch_chapter` for more information.
+
Context
An object in the system that is found during :term:`traversal` or
:term:`URL dispatch` based on URL data; if it's found via
@@ -251,14 +253,13 @@ Glossary
Routes
A `system by Ben Bangert <http://routes.groovie.org/>`_ which
parses URLs and compares them against a number of user defined
- mappings. In terms of :mod:`repoze.bfg`, a Route can supplant
- graph traversal when deciding which *view* should be called. See
- :ref:`urldispatch_chapter` for more information about Routes integration
- in :mod:`repoze.bfg`.
+ mappings. The URL pattern matching syntax in :mod:`repoze.bfg` is
+ inspired by the Routes syntax (which was inspired by Ruby On
+ Rails pattern syntax).
Route
- A single pattern matched by the :term:`Routes` subsystem, which
- generally resolves to a :term:`root factory` (and then ultimately
- a :term:`view`). See also :term:`url dispatch`.
+ A single pattern matched by the :term:`url dispatch` subsystem,
+ which generally resolves to a :term:`root factory` (and then
+ ultimately a :term:`view`). See also :term:`url dispatch`.
ZCML
`Zope Configuration Markup Language
<http://www.muthukadan.net/docs/zca.html#zcml>`_, the XML dialect
diff --git a/docs/narr/project.rst b/docs/narr/project.rst
index 3de146e8e..b465082eb 100644
--- a/docs/narr/project.rst
+++ b/docs/narr/project.rst
@@ -92,10 +92,10 @@ application's Python code and templates.
<http://www.sqlalchemy.org/>`_ also exist. Use ``paster create -t
bfg_zodb`` to create a project that depends on ZODB. Use ``paster
create -t bfg_routesalchemy`` to create a project that depends on
- SQLAlchemy and Routes (uses only :term:`URL dispatch` and no
- :term:`traversal`). Use ``paster create -t bfg_alchemy`` to create
- a project that depends on SQLAlchemy but *not* Routes (uses
- only :term:`traversal` and no :term:`URL dispatch`).
+ SQLAlchemy and :term:`URL dispatch` (no :term:`traversal`). Use
+ ``paster create -t bfg_alchemy`` to create a project that depends
+ on SQLAlchemy but *not* :term:`URL dispatch` (uses only
+ :term:`traversal`).
Installing your Newly Created Project for Development
-----------------------------------------------------
diff --git a/docs/narr/router.rst b/docs/narr/router.rst
index 2bf7f4ca0..a7e19f134 100644
--- a/docs/narr/router.rst
+++ b/docs/narr/router.rst
@@ -20,23 +20,23 @@ processing?
:mod:`repoze.bfg` :term:`router` object.
#. To service :term:`url dispatch`, the :mod:`repoze.bfg`
- :term:`router` calls a :term:`Routes` "mapper" callable, which acts
- as a :term:`root factory`. The job of the mapper is to examine the
- ``PATH_INFO`` and other various keys in the environment to
- determine whether any user-defined :term:`route` matches the
- current WSGI environment. The :term:`router` passes the WSGI
- environment as an argument to the mapper.
+ :term:`router` calls a :term:`URL dispatch` "root factory wrapper"
+ callable, which acts as a :term:`root factory`. The job of the
+ mapper is to examine the ``PATH_INFO`` and other various keys in
+ the environment to determine whether any user-defined :term:`route`
+ matches the current WSGI environment. The :term:`router` passes
+ the WSGI environment as an argument to the mapper.
#. If any route matches, the WSGI environment is mutated; a
``bfg.routes.route`` key and a ``bfg.routes.matchdict`` are added
to the WSGI environment. If a route *doesn't* match, neither of
these keys is added to the WSGI environment.
-#. Regardless of whether any route matched or not, the Routes mapper
- returns a root object. If a particular :term:`route` named a
- ``factory`` argument, this factory is used to generate the root
- object, otherwise a default :term:`root factory` is used. If a
- root factory argument was passed to the
+#. Regardless of whether any route matched or not, the :term:`URL
+ dispatch` mapper returns a root object. If a particular
+ :term:`route` named a ``factory`` argument, this factory is used to
+ generate the root object, otherwise a default :term:`root factory`
+ is used. If a root factory argument was passed to the
``repoze.bfg.router.make_app``, that callable is used to generate
the root object. If the root factory argument passed to
``make_app`` is ``None``, a default root factory is used to
diff --git a/docs/narr/urldispatch.rst b/docs/narr/urldispatch.rst
index 356a14aef..3d3dae847 100644
--- a/docs/narr/urldispatch.rst
+++ b/docs/narr/urldispatch.rst
@@ -5,19 +5,11 @@ URL Dispatch
It is common for :mod:`repoze.bfg` developers to rely on
:term:`traversal` to map URLs to code. However, :mod:`repoze.bfg` can
-also map URLs to code via :term:`URL dispatch` using the
-:term:`Routes` framework. The :term:`Routes` framework is a Python
-reimplementation of the `Rails routes system
-<http://manuals.rubyonrails.com/read/chapter/65>`_. It is a mechanism
-which allows you to declaratively map URLs to code.
-
-.. note:: In common :term:`Routes` lingo, the code that it maps URLs
- to is defined by a *controller* and an *action*. However,
- neither concept (controller nor action) exists within
- :mod:`repoze.bfg`. Instead, when you map a URL pattern to
- code in bfg, you will map the URL patterm to a :term:`view`.
- Once the context and view are found, the view will be called
- with a :term:`context` and a :term:`request`.
+also map URLs to code via :term:`URL dispatch`. The presence of
+``<route>`` statements in ZCML are a sign that you're using URL
+dispatch. Using ``<route>`` statements in ZCML allows you to
+declaratively map URLs to code. The syntax of the pattern matching
+language used by :mod:`repoze.bfg` is close to that of :term:`Routes`.
It often makes a lot of sense to use :term:`URL dispatch` instead of
:term:`traversal` in an application that has no natural hierarchy.
@@ -39,13 +31,6 @@ To allow for URL dispatch to be used, the :mod:`repoze.bfg` framework
allows you to inject ``route`` ZCML directives into your application's
``configure.zcml`` file.
-.. note:: Each ZCML ``route`` statement equates to a call to the
- :term:`Routes` ``Mapper`` object's ``connect`` method. See
- `Setting up routes
- <http://routes.groovie.org/manual.html#setting-up-routes>`_
- for examples of using a Routes ``Mapper`` object outside of
- :mod:`repoze.bfg`.
-
When any ``route`` ZCML directive is present in an application's
``configure.zcml``, "under the hood" :mod:`repoze.bfg` wraps the
:term:`root factory` in a special ``RoutesRootFactory`` instance. The
@@ -114,82 +99,10 @@ factory
e.g. ``mypackage.models.MyFactoryClass``. If this argument is not
specified, a default root factory will be used.
-encoding
-
- The `URL encoding <http://routes.groovie.org/manual.html#unicode>`_
- for a match returned by this route.
-
-static
-
- A boolean (true/false) indicating whether this route is `static
- <http://routes.groovie.org/manual.html#static-named-routes>`_.
-
-filter
-
- A Python dotted-path name to a Routes `filter function
- <http://routes.groovie.org/manual.html#filter-functions>`_.
-
request_type
- The name of the HTTP method used as the Routes `condition method
- <http://routes.groovie.org/manual.html#conditions>`_. A string,
- e.g. ``GET`` or ``POST``. Note that :term:`interface` references
- don't work here as they do in the ``view`` decorator or ``bfg_view``
- ZCML directive. Only strings representing an HTTP method will work.
-
-condition_method
-
- An alias for the ``request_type`` attribute.
-
-condition_subdomain
-
- A field that contain a Routes `condition subdomain
- <http://routes.groovie.org/manual.html#conditions>`_.
-
-condition_function
-
- A python-dotted path name to a Routes `condition function
- <http://routes.groovie.org/manual.html#conditions>`_.
-
-explicit
-
- A boolean (true/false) indicating whether this route is `explicit
- <http://routes.groovie.org/manual.html#overriding-route-memory>`_.
-
-subdomains
-
- A field that contain one or more Routes `condition subdomains
- <http://routes.groovie.org/manual.html#conditions>`_. If this field
- is used, the ``condition_subdomain`` attribute is ignored.
-
-Using the ``requirement`` Subdirective
---------------------------------------
-
-The ``route`` directive supports a subdirective named ``requirement``
-that allows you to specify Routes `requirement
-<http://routes.groovie.org/manual.html#requirements>`_ expressions.
-
-For example:
-
-.. code-block:: xml
- :linenos:
-
- <route
- name="archive"
- path="archives/:year/:month"
- view=".views.archive_view">
-
- <requirement
- attr="year"
- expr="d{2,4}"
- />
-
- <requirement
- attr="month"
- expr="d{1,2}"
- />
-
- </route>
+ A string representing an HTTP method name, e.g. ``GET`` or ``POST``
+ or an interface representing a :term:`request type`.
Example 1
---------
@@ -321,8 +234,8 @@ Example 4
---------
An example of configuring a ``view`` declaration in ``configure.zcml``
-that maps a context found via :term:`Routes` URL dispatch to a view
-function is as follows:
+that maps a context found via URL dispatch to a view function is as
+follows:
.. code-block:: xml
:linenos:
@@ -364,8 +277,8 @@ application runs, if any URL matches the pattern
``archives/:article``, the ``.views.articles_view`` view will be
called with its :term:`context` as a instance of the ``Article``
class. The ``Article`` instance will have keys and values matching
-the keys and values in the Routes routing dictionary associated with
-the request.
+the keys and values in the routing dictionary associated with the
+request.
In this case in particular, when a user visits
``/archives/something``, the context will be an instance of the
@@ -399,11 +312,13 @@ this.
.. code-block:: python
from repoze.bfg.url import route_url
- url = route_url(request, 'foo', a='1', b='2', c='3')
+ url = route_url('foo', request, a='1', b='2', c='3')
This would return something like the string
``http://example.com/1/2/3`` (at least if the current protocol and
-hostname implied ``http:/example.com``).
+hostname implied ``http:/example.com``). See the
+:mod:`repoze.bfg.url.route_url` API documentation for more
+information.
Cleaning Up After a Request
---------------------------
diff --git a/docs/narr/urlmapping.rst b/docs/narr/urlmapping.rst
index 21f6235f8..269061e40 100644
--- a/docs/narr/urlmapping.rst
+++ b/docs/narr/urlmapping.rst
@@ -13,11 +13,12 @@ components. Examples: `Django's URL dispatcher
<http://www.djangoproject.com/documentation/url_dispatch/>`_ and the
:term:`Routes` URL mapping system.
-:mod:`repoze.bfg` supports :term:`URL dispatch` via :term:`Routes`.
-:term:`URL dispatch` is convenient and straightforward. When you
-limit your application to using URL dispatch, you know every URL that
-your application might generate or respond to, and all the URL
-matching elements are listed in a single place.
+:mod:`repoze.bfg` supports :term:`URL dispatch` via a subsystem that
+was inpsired by :term:`Routes`. :term:`URL dispatch` is convenient
+and straightforward. When you limit your application to using URL
+dispatch, you know every URL that your application might generate or
+respond to, and all the URL matching elements are listed in a single
+place.
Like :term:`Zope`, :mod:`repoze.bfg`, in contrast to URL dispatch, can
also map URLs to code slightly differently, by using using object
@@ -35,8 +36,8 @@ Differences Between Traversal and URL Dispatch
item "below" ``members`` in the URL represents a member in the system.
You just match everything "below" ``members`` to a particular view.
-For example, you might configure a :term:`Routes` URL map to match
-against the following URL patterns::
+For example, you might configure a :term:`route` to match against the
+following URL patterns::
archives/:year/:month/:day
members/:membername
diff --git a/docs/tutorials/bfgwiki2/installation.rst b/docs/tutorials/bfgwiki2/installation.rst
index 0a02ce9e1..1e43c3abd 100644
--- a/docs/tutorials/bfgwiki2/installation.rst
+++ b/docs/tutorials/bfgwiki2/installation.rst
@@ -122,7 +122,7 @@ Making a Project
Your next step is to create a project. BFG supplies a variety of
templates to generate sample projects. We will use the
-:term:`SQLAlchemy` + :term:`Routes` -oriented template.
+:term:`SQLAlchemy` + :term:`URL Dispatch` -oriented template.
The below instructions assume your current working directory is the
"virtualenv" named "bigfntut".