From a232fcf1d23c9943ce11b9191a772bef38cc41a3 Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Tue, 16 Sep 2008 03:39:36 +0000 Subject: Document url dispatch in narrative form. --- docs/api/urldispatch.rst | 48 ------------------------------------------------ 1 file changed, 48 deletions(-) (limited to 'docs/api/urldispatch.rst') diff --git a/docs/api/urldispatch.rst b/docs/api/urldispatch.rst index 40b22e5bc..2ebdd6de4 100644 --- a/docs/api/urldispatch.rst +++ b/docs/api/urldispatch.rst @@ -8,51 +8,3 @@ .. autoclass:: RoutesMapper :members: -An example of configuring a ``bfg:view`` stanza in ``configure.zcml`` -that maps a context found via :term:`Routes` URL dispatch to a view -function is as follows: - -.. code-block:: xml - :linenos: - - - -All context objects found via Routes URL dispatch will provide the -``IRoutesContext`` interface (attached dynamically). You might then -configure the ``RoutesMapper`` like so: - -.. code-block:: python - :linenos: - - def fallback_get_root(environ): - return {} # the graph traversal root is empty in this example - - class Article(object): - def __init__(self, **kw): - self.__dict__update(kw) - - get_root = RoutesMapper(fallback_get_root) - get_root.connect('archives/:article', controller='articles', - context_factory=Article) - - import myapp - from repoze.bfg.router import make_app - - app = make_app(get_root, myapp) - -The effect of this configuration: when this :mod:`repoze.bfg` -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 attributes matching the -keys and values in the Routes 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 -Article class and it will have an ``article`` attribute with the value -of ``something``. -- cgit v1.2.3