diff options
| author | Chris McDonough <chrism@agendaless.com> | 2010-09-08 04:25:35 +0000 |
|---|---|---|
| committer | Chris McDonough <chrism@agendaless.com> | 2010-09-08 04:25:35 +0000 |
| commit | 74409d12f7eb085bc992a200cc74799e4d1ff355 (patch) | |
| tree | 14b10948171be45b425f87122be156a7dc11c117 /repoze/bfg/zcml.py | |
| parent | 68469214646debcdcea662f34b41f41e0ae8db12 (diff) | |
| download | pyramid-74409d12f7eb085bc992a200cc74799e4d1ff355.tar.gz pyramid-74409d12f7eb085bc992a200cc74799e4d1ff355.tar.bz2 pyramid-74409d12f7eb085bc992a200cc74799e4d1ff355.zip | |
- The ``repoze.bfg.urldispatch.Route`` constructor (not an API) now
accepts a different ordering of arguments. Previously it was
``(pattern, name, factory=None, predicates=())``. It is now
``(name, pattern, factory=None, predicates=())``. This is in
support of consistency with ``configurator.add_route``.
- The ``repoze.bfg.urldispatch.RoutesMapper.connect`` method (not an
API) now accepts a different ordering of arguments. Previously it
was ``(pattern, name, factory=None, predicates=())``. It is now
``(name, pattern, factory=None, predicates=())``. This is in
support of consistency with ``configurator.add_route``.
- The ``repoze.bfg.urldispatch.RoutesMapper`` object now has a
``get_route`` method which returns a single Route object or
``None``.
- A new interface ``repoze.bfg.interfaces.IRoute`` was added. The
``repoze.bfg.urldispatch.Route`` object implements this interface.
- The canonical attribute for accessing the routing pattern from a
route object is now ``pattern`` rather than ``path``.
- The argument to ``repoze.bfg.configuration.Configurator.add_route``
which was previously called ``path`` is now called ``pattern`` for
better explicability. For backwards compatibility purposes, passing
a keyword argument named ``path`` to ``add_route`` will still work
indefinitely.
- The ``path`` attribute to the ZCML ``route`` directive is now named
``pattern`` for better explicability. The older ``path`` attribute
will continue to work indefinitely.
- All narrative, API, and tutorial docs which referred to a route
pattern as a ``path`` have now been updated to refer to them as a
``pattern``.
- The routesalchemy template has been updated to use ``pattern`` in
its route declarations rather than ``path``.
Diffstat (limited to 'repoze/bfg/zcml.py')
| -rw-r--r-- | repoze/bfg/zcml.py | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/repoze/bfg/zcml.py b/repoze/bfg/zcml.py index 820dc9442..5320554bc 100644 --- a/repoze/bfg/zcml.py +++ b/repoze/bfg/zcml.py @@ -221,7 +221,9 @@ class IRouteDirective(Interface): """ The interface for the ``route`` ZCML directive """ name = TextLine(title=u'name', required=True) - path = TextLine(title=u'path', required=True) + pattern = TextLine(title=u'pattern', required=False) + # alias for pattern + path = TextLine(title=u'path', required=False) factory = GlobalObject(title=u'context factory', required=False) view = GlobalObject(title=u'view', required=False) @@ -263,7 +265,7 @@ class IRouteDirective(Interface): def route(_context, name, - path, + pattern=None, view=None, view_for=None, permission=None, @@ -282,7 +284,8 @@ def route(_context, view_renderer=None, view_context=None, traverse=None, - use_global_views=False): + use_global_views=False, + path=None): """ Handle ``route`` ZCML directives """ # the strange ordering of the request kw args above is for b/w @@ -300,11 +303,17 @@ def route(_context, if view_renderer and '.' in view_renderer: view_renderer = path_spec(_context, view_renderer) + if pattern is None: + pattern = path + + if pattern is None: + raise ConfigurationError('route directive must include a "pattern"') + def register(): config = Configurator(reg, package=_context.package) config.add_route( name, - path, + pattern, factory=factory, header=header, xhr=xhr, |
