Skip to content

Commit

Permalink
More docs
Browse files Browse the repository at this point in the history
  • Loading branch information
asvetlov committed Jan 25, 2016
1 parent c0181d6 commit d1dc4bb
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions docs/web_reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1395,6 +1395,12 @@ After that he may add a :term:`route` by calling :meth:`Resource.add_route`.

router.add_resource(path).add_route(method, handler)

Resource with a *name* is called *named resource*.
The main purpose of *named resource* is constructing URL by route name for
passing it into *template engine* for example::

url = app.router['resource_name'].url(query={'a': 1, 'b': 2})

Resource classes hierarhy::

AbstractResource
Expand All @@ -1411,6 +1417,9 @@ Resource classes hierarhy::
Inherited from :class:`collections.abc.Sized` and
:class:`collections.abc.Iterable`.

``len(resource)`` returns amount of :term:`route`\s belongs to the resource,
``for route in resource: ...`` allows to iterate over these routes.

.. attribute:: name

Read-only *name* of resource or ``None``.
Expand Down Expand Up @@ -1490,17 +1499,21 @@ Route has HTTP method (wildcard ``'*'`` is an option),

Every route belong to some resource.

Route classes hierarhy::

AbstractRoute
ResourceRoute
Route
PlainRoute
DynamicRoute
StaticRoute
SystemRoute

User should not instantiate route classes by hand but can give *named
route instance* by ``router[name]`` if he have added route by
:meth:`UrlDispatcher.add_route` or :meth:`UrlDispatcher.add_static`
calls with non-empty *name* parameter.

The main usage of *named routes* is constructing URL by route name for
passing it into *template engine* for example::

url = app.router['route_name'].url(query={'a': 1, 'b': 2})

There are three concrete route classes:

Expand Down

0 comments on commit d1dc4bb

Please sign in to comment.