diff --git a/doc/index.rst b/doc/index.rst index b06ec36..1385b29 100644 --- a/doc/index.rst +++ b/doc/index.rst @@ -14,6 +14,10 @@ Contents: :maxdepth: 2 rationale + +.. toctree:: + :maxdepth: 1 + reference/index *Milla* is released under the terms of the `Apache License, version 2.0`_. diff --git a/src/milla/dispatch/routing.py b/src/milla/dispatch/routing.py index 0ef4e6f..34ddfde 100644 --- a/src/milla/dispatch/routing.py +++ b/src/milla/dispatch/routing.py @@ -26,6 +26,7 @@ import re import sys import urllib import urlparse +import warnings class Router(object): '''A dispatcher that maps arbitrary paths to controller callables @@ -220,11 +221,20 @@ class Generator(object): A common pattern is to wrap this in a stub function:: url = Generator(request).generate + + .. deprecated:: 0.2 + Use :py:meth:`milla.Request.relative_url` instead. ''' def __init__(self, request, path_only=True): self.request = request self.path_only = path_only + warnings.warn( + 'Use of Generator is deprecated; ' + 'use milla.Request.relative_url instead', + DeprecationWarning, + stacklevel=2 + ) def generate(self, *segments, **vars): '''Combines segments and the application's URL into a new URL @@ -234,10 +244,7 @@ class Generator(object): while path.startswith('/'): path = path[1:] - url = self.request.relative_url(path, to_application=True) - if self.path_only: - split = urlparse.urlsplit(url) - url = split.path - if vars: - url += '?' + urllib.urlencode(vars) - return url + return self.request.relative_url(path, + to_application=True, + path_only=self.path_only, + **vars)