[Python-modules-commits] [routes] 02/05: Import routes_2.3.1.orig.tar.gz
Piotr Ożarowski
piotr at moszumanska.debian.org
Sat Jul 30 21:40:31 UTC 2016
This is an automated email from the git hooks/post-receive script.
piotr pushed a commit to branch master
in repository routes.
commit eb31e071b2f4eb519cf62649ffbe448c71aa5c2a
Author: Piotr Ożarowski <piotr at debian.org>
Date: Sat Jul 30 23:18:45 2016 +0200
Import routes_2.3.1.orig.tar.gz
---
CHANGELOG.rst | 23 +++++++++++-
LICENSE.txt | 2 +-
PKG-INFO | 26 ++++++++++++--
Routes.egg-info/PKG-INFO | 26 ++++++++++++--
Routes.egg-info/requires.txt | 5 ++-
docs/conf.py | 6 ++--
docs/modules/middleware.rst | 1 -
routes/mapper.py | 84 ++++++++++++++++++++++++++++++++++----------
routes/middleware.py | 7 +++-
routes/util.py | 44 +++++++++++++++--------
setup.py | 10 ++++--
11 files changed, 187 insertions(+), 47 deletions(-)
diff --git a/CHANGELOG.rst b/CHANGELOG.rst
index 777b3d7..bde71f9 100644
--- a/CHANGELOG.rst
+++ b/CHANGELOG.rst
@@ -1,6 +1,27 @@
Routes Changelog
%%%%%%%%%%%%%%%%
+Release 2.3.1 (March 30, 2016)
+==============================
+* Backwards compatability fix - connect should work with mandatory
+ routename and optional path. Patch by Davanum Srinivas (PR #65).
+
+Release 2.3 (March 28, 2016)
+============================
+* Fix sub_domain equivalence check. Patch by Nikita Uvarov
+* Add support for protocol-relative URLs generation (i.e. starting with double
+ slash ``//``). PR #60. Patch by Sviatoslav Sydorenko.
+* Add support for the ``middleware`` extra requirement, making possible to
+ depend on ``webob`` optionally. PR #59. Patch by Sviatoslav Sydorenko.
+* Fix matching of an empty string route, which led to exception in earlier
+ versions. PR #58. Patch by Sviatoslav Sydorenko.
+* Add support for the ``requirements`` option when using
+ mapper.resource to create routes. PR #57. Patch by Sean Dague.
+* Concatenation fix when using submappers with path prefixes. Multiple
+ submappers combined the path prefix inside the controller argument in
+ non-obvious ways. The controller argument will now be properly carried
+ through when using submappers. PR #28.
+
Release 2.2 (July 21, 2015)
===========================
* Fix Python 3 support. Patch by Victor Stinner.
@@ -418,7 +439,7 @@ Release 1.0 (Nov. 21st, 2005)
Or::
- from routes import request_confg, Mapper
+ from routes import request_config, Mapper
The following names are available for importing from routes::
diff --git a/LICENSE.txt b/LICENSE.txt
index 493ea52..5a11de7 100644
--- a/LICENSE.txt
+++ b/LICENSE.txt
@@ -1,4 +1,4 @@
-Copyright (c) 2005-2015 Ben Bangert <ben at groovie.org>
+Copyright (c) 2005-2016 Ben Bangert <ben at groovie.org>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
diff --git a/PKG-INFO b/PKG-INFO
index b64c5d7..8f24e00 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,6 +1,6 @@
Metadata-Version: 1.1
Name: Routes
-Version: 2.2
+Version: 2.3.1
Summary: Routing Recognition and Generation Tools
Home-page: http://routes.readthedocs.org/
Author: Ben Bangert
@@ -24,6 +24,27 @@ Description: Routes is a Python re-implementation of the Rails routes system for
Routes Changelog
%%%%%%%%%%%%%%%%
+ Release 2.3.1 (March 30, 2016)
+ ==============================
+ * Backwards compatability fix - connect should work with mandatory
+ routename and optional path. Patch by Davanum Srinivas (PR #65).
+
+ Release 2.3 (March 28, 2016)
+ ============================
+ * Fix sub_domain equivalence check. Patch by Nikita Uvarov
+ * Add support for protocol-relative URLs generation (i.e. starting with double
+ slash ``//``). PR #60. Patch by Sviatoslav Sydorenko.
+ * Add support for the ``middleware`` extra requirement, making possible to
+ depend on ``webob`` optionally. PR #59. Patch by Sviatoslav Sydorenko.
+ * Fix matching of an empty string route, which led to exception in earlier
+ versions. PR #58. Patch by Sviatoslav Sydorenko.
+ * Add support for the ``requirements`` option when using
+ mapper.resource to create routes. PR #57. Patch by Sean Dague.
+ * Concatenation fix when using submappers with path prefixes. Multiple
+ submappers combined the path prefix inside the controller argument in
+ non-obvious ways. The controller argument will now be properly carried
+ through when using submappers. PR #28.
+
Release 2.2 (July 21, 2015)
===========================
* Fix Python 3 support. Patch by Victor Stinner.
@@ -441,7 +462,7 @@ Description: Routes is a Python re-implementation of the Rails routes system for
Or::
- from routes import request_confg, Mapper
+ from routes import request_config, Mapper
The following names are available for importing from routes::
@@ -483,3 +504,4 @@ Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.2
Classifier: Programming Language :: Python :: 3.3
Classifier: Programming Language :: Python :: 3.4
+Classifier: Programming Language :: Python :: 3.5
diff --git a/Routes.egg-info/PKG-INFO b/Routes.egg-info/PKG-INFO
index b64c5d7..8f24e00 100644
--- a/Routes.egg-info/PKG-INFO
+++ b/Routes.egg-info/PKG-INFO
@@ -1,6 +1,6 @@
Metadata-Version: 1.1
Name: Routes
-Version: 2.2
+Version: 2.3.1
Summary: Routing Recognition and Generation Tools
Home-page: http://routes.readthedocs.org/
Author: Ben Bangert
@@ -24,6 +24,27 @@ Description: Routes is a Python re-implementation of the Rails routes system for
Routes Changelog
%%%%%%%%%%%%%%%%
+ Release 2.3.1 (March 30, 2016)
+ ==============================
+ * Backwards compatability fix - connect should work with mandatory
+ routename and optional path. Patch by Davanum Srinivas (PR #65).
+
+ Release 2.3 (March 28, 2016)
+ ============================
+ * Fix sub_domain equivalence check. Patch by Nikita Uvarov
+ * Add support for protocol-relative URLs generation (i.e. starting with double
+ slash ``//``). PR #60. Patch by Sviatoslav Sydorenko.
+ * Add support for the ``middleware`` extra requirement, making possible to
+ depend on ``webob`` optionally. PR #59. Patch by Sviatoslav Sydorenko.
+ * Fix matching of an empty string route, which led to exception in earlier
+ versions. PR #58. Patch by Sviatoslav Sydorenko.
+ * Add support for the ``requirements`` option when using
+ mapper.resource to create routes. PR #57. Patch by Sean Dague.
+ * Concatenation fix when using submappers with path prefixes. Multiple
+ submappers combined the path prefix inside the controller argument in
+ non-obvious ways. The controller argument will now be properly carried
+ through when using submappers. PR #28.
+
Release 2.2 (July 21, 2015)
===========================
* Fix Python 3 support. Patch by Victor Stinner.
@@ -441,7 +462,7 @@ Description: Routes is a Python re-implementation of the Rails routes system for
Or::
- from routes import request_confg, Mapper
+ from routes import request_config, Mapper
The following names are available for importing from routes::
@@ -483,3 +504,4 @@ Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.2
Classifier: Programming Language :: Python :: 3.3
Classifier: Programming Language :: Python :: 3.4
+Classifier: Programming Language :: Python :: 3.5
diff --git a/Routes.egg-info/requires.txt b/Routes.egg-info/requires.txt
index db0d3f7..d0f9970 100644
--- a/Routes.egg-info/requires.txt
+++ b/Routes.egg-info/requires.txt
@@ -1,2 +1,5 @@
six
-repoze.lru>=0.3
\ No newline at end of file
+repoze.lru>=0.3
+
+[middleware]
+webob
\ No newline at end of file
diff --git a/docs/conf.py b/docs/conf.py
index 6673a37..467a6be 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -36,15 +36,15 @@ master_doc = 'index'
# General substitutions.
project = 'Routes'
-copyright = '2005-2015, Ben Bangert, Mike Orr'
+copyright = '2005-2016, Ben Bangert, Mike Orr, and numerous contributers'
# The default replacements for |version| and |release|, also used in various
# other places throughout the built documents.
#
# The short X.Y version.
-version = '1.13'
+version = '2.3'
# The full version, including alpha/beta/rc tags.
-release = '1.13'
+release = '2.3.1'
# There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used:
diff --git a/docs/modules/middleware.rst b/docs/modules/middleware.rst
index eef80a8..9b12e79 100644
--- a/docs/modules/middleware.rst
+++ b/docs/modules/middleware.rst
@@ -2,7 +2,6 @@
==================================================
.. automodule:: routes.middleware
-.. currentmodule:: routes.middleware
Module Contents
---------------
diff --git a/routes/mapper.py b/routes/mapper.py
index 583309e..48bba45 100644
--- a/routes/mapper.py
+++ b/routes/mapper.py
@@ -116,7 +116,19 @@ class SubMapperParent(object):
controller = resource_name or collection_name
if path_prefix is None:
- path_prefix = '/' + collection_name
+ if collection_name is None:
+ path_prefix_str = ''
+ else:
+ path_prefix_str = '/{collection_name}'
+ else:
+ if collection_name is None:
+ path_prefix_str = "{pre}"
+ else:
+ path_prefix_str = "{pre}/{collection_name}"
+
+ # generate what will be the path prefix for the collection
+ path_prefix = path_prefix_str.format(pre=path_prefix,
+ collection_name=collection_name)
collection = SubMapper(self, collection_name=collection_name,
resource_name=resource_name,
@@ -148,30 +160,44 @@ class SubMapper(SubMapperParent):
self.formatted = getattr(obj, 'formatted', None)
if self.formatted is None:
self.formatted = True
+ self.add_actions(actions or [], **kwargs)
- self.add_actions(actions or [])
-
- def connect(self, *args, **kwargs):
+ def connect(self, routename, path=None, **kwargs):
newkargs = {}
- newargs = args
+ _routename = routename
+ _path = path
for key, value in six.iteritems(self.kwargs):
if key == 'path_prefix':
- if len(args) > 1:
- newargs = (args[0], self.kwargs[key] + args[1])
+ if path is not None:
+ # if there's a name_prefix, add it to the route name
+ # and if there's a path_prefix
+ _path = ''.join((self.kwargs[key], path))
+ else:
+ _path = ''.join((self.kwargs[key], routename))
+ elif key == 'name_prefix':
+ if path is not None:
+ # if there's a name_prefix, add it to the route name
+ # and if there's a path_prefix
+ _routename = ''.join((self.kwargs[key], routename))
else:
- newargs = (self.kwargs[key] + args[0],)
+ _routename = None
elif key in kwargs:
if isinstance(value, dict):
newkargs[key] = dict(value, **kwargs[key]) # merge dicts
- elif key == 'controller':
- newkargs[key] = kwargs[key]
else:
- newkargs[key] = value + kwargs[key]
+ # Originally used this form:
+ # newkargs[key] = value + kwargs[key]
+ # New version avoids the inheritance concatenation issue
+ # with submappers. Only prefixes concatenate, everything
+ # else overrides in submappers.
+ newkargs[key] = kwargs[key]
else:
newkargs[key] = self.kwargs[key]
for key in kwargs:
if key not in self.kwargs:
newkargs[key] = kwargs[key]
+
+ newargs = (_routename, _path)
return self.obj.connect(*newargs, **newkargs)
def link(self, rel=None, name=None, action=None, method='GET',
@@ -263,8 +289,8 @@ class SubMapper(SubMapperParent):
"""Generates the "delete" action for a collection member submapper."""
return self.action(action='delete', method='DELETE', **kwargs)
- def add_actions(self, actions):
- [getattr(self, action)() for action in actions]
+ def add_actions(self, actions, **kwargs):
+ [getattr(self, action)(**kwargs) for action in actions]
# Provided for those who prefer using the 'with' syntax in Python 2.5+
def __enter__(self):
@@ -687,10 +713,10 @@ class Mapper(SubMapperParent):
resultdict = m.match('/joe/sixpack')
"""
- if not url and not environ:
+ if url is None and not environ:
raise RoutesException('URL or environ must be provided')
- if not url:
+ if url is None:
url = environ['PATH_INFO']
result = self._match(url, environ)
@@ -711,10 +737,10 @@ class Mapper(SubMapperParent):
resultdict, route_obj = m.match('/joe/sixpack')
"""
- if not url and not environ:
+ if url is None and not environ:
raise RoutesException('URL or environ must be provided')
- if not url:
+ if url is None:
url = environ['PATH_INFO']
result = self._match(url, environ)
if self.debug:
@@ -763,7 +789,11 @@ class Mapper(SubMapperParent):
six.text_type(kargs).encode('utf8')
if self.urlcache is not None:
- cache_key_script_name = '%s:%s' % (script_name, cache_key)
+ if six.PY3:
+ cache_key_script_name = b':'.join((script_name.encode('utf-8'),
+ cache_key))
+ else:
+ cache_key_script_name = '%s:%s' % (script_name, cache_key)
# Check the url cache to see if it exists, use it if it does
val = self.urlcache.get(cache_key_script_name, self)
@@ -956,6 +986,22 @@ class Mapper(SubMapperParent):
# GET /category/7/message/1
# has named route "category_message"
+ ``requirements``
+
+ A dictionary that restricts the matching of a
+ variable. Can be used when matching variables with path_prefix.
+
+ Example::
+
+ map.resource('message', 'messages',
+ path_prefix='{project_id}/',
+ requirements={"project_id": R"\d+"})
+ # POST /01234/message
+ # success, project_id is set to "01234"
+ # POST /foo/message
+ # 404 not found, won't be matched by this route
+
+
``parent_resource``
A ``dict`` containing information about the parent
resource, for creating a nested resource. It should contain
@@ -1079,6 +1125,8 @@ class Mapper(SubMapperParent):
'_parent_resource': parent_resource,
'_filter': kwargs.get('_filter')
}
+ if 'requirements' in kwargs:
+ options['requirements'] = kwargs['requirements']
def requirements_for(meth):
"""Returns a new dict to be used for all route creation as the
diff --git a/routes/middleware.py b/routes/middleware.py
index 850e06e..885b9d9 100644
--- a/routes/middleware.py
+++ b/routes/middleware.py
@@ -12,7 +12,12 @@ log = logging.getLogger('routes.middleware')
class RoutesMiddleware(object):
"""Routing middleware that handles resolving the PATH_INFO in
- addition to optionally recognizing method overriding."""
+ addition to optionally recognizing method overriding.
+
+ .. Note::
+ This module requires webob to be installed. To depend on it, you may
+ list routes[middleware] in your ``requirements.txt``
+ """
def __init__(self, wsgi_app, mapper, use_method_override=True,
path_info=True, singleton=True):
"""Create a Route middleware object
diff --git a/routes/util.py b/routes/util.py
index baeeac7..c48445f 100644
--- a/routes/util.py
+++ b/routes/util.py
@@ -93,10 +93,12 @@ def _subdomain_check(kargs, mapper, environ):
port = ''
if len(hostmatch) > 1:
port += ':' + hostmatch[1]
- sub_match = re.compile('^.+?\.(%s)$' % mapper.domain_match)
- domain = re.sub(sub_match, r'\1', host)
+
+ match = re.match('^(.+?)\.(%s)$' % mapper.domain_match, host)
+ host_subdomain, domain = match.groups() if match else (None, host)
+
subdomain = as_unicode(subdomain, mapper.encoding)
- if subdomain and not host.startswith(subdomain) and \
+ if subdomain and host_subdomain != subdomain and \
subdomain not in mapper.sub_domains_ignore:
kargs['_host'] = subdomain + '.' + domain + port
elif (subdomain in mapper.sub_domains_ignore or \
@@ -180,15 +182,19 @@ def url_for(*args, **kargs):
"""
anchor = kargs.get('anchor')
host = kargs.get('host')
- protocol = kargs.get('protocol')
+ protocol = kargs.pop('protocol', None)
qualified = kargs.pop('qualified', None)
# Remove special words from kargs, convert placeholders
- for key in ['anchor', 'host', 'protocol']:
+ for key in ['anchor', 'host']:
if kargs.get(key):
del kargs[key]
if key+'_' in kargs:
kargs[key] = kargs.pop(key+'_')
+
+ if 'protocol_' in kargs:
+ kargs['protocol_'] = protocol
+
config = request_config()
route = None
static = False
@@ -250,21 +256,23 @@ def url_for(*args, **kargs):
newargs = _screenargs(kargs, config.mapper, environ)
anchor = newargs.pop('_anchor', None) or anchor
host = newargs.pop('_host', None) or host
- protocol = newargs.pop('_protocol', None) or protocol
+ protocol = newargs.pop('_protocol', protocol)
url = config.mapper.generate(*route_args, **newargs)
if anchor is not None:
url += '#' + _url_quote(anchor, encoding)
- if host or protocol or qualified:
+ if host or (protocol is not None) or qualified:
if not host and not qualified:
# Ensure we don't use a specific port, as changing the protocol
# means that we most likely need a new port
host = config.host.split(':')[0]
elif not host:
host = config.host
- if not protocol:
+ if protocol is None:
protocol = config.protocol
+ if protocol != '':
+ protocol += ':'
if url is not None:
- url = protocol + '://' + host + url
+ url = protocol + '//' + host + url
if not ascii_characters(url) and url is not None:
raise GenerationException("url_for can only return a string, got "
@@ -324,16 +332,19 @@ class URLGenerator(object):
"""
anchor = kargs.get('anchor')
host = kargs.get('host')
- protocol = kargs.get('protocol')
+ protocol = kargs.pop('protocol', None)
qualified = kargs.pop('qualified', None)
# Remove special words from kargs, convert placeholders
- for key in ['anchor', 'host', 'protocol']:
+ for key in ['anchor', 'host']:
if kargs.get(key):
del kargs[key]
if key+'_' in kargs:
kargs[key] = kargs.pop(key+'_')
+ if 'protocol_' in kargs:
+ kargs['protocol_'] = protocol
+
route = None
use_current = '_use_current' in kargs and kargs.pop('_use_current')
@@ -396,12 +407,13 @@ class URLGenerator(object):
anchor = anchor or newargs.pop('_anchor', None)
host = host or newargs.pop('_host', None)
- protocol = protocol or newargs.pop('_protocol', None)
+ if protocol is None:
+ protocol = newargs.pop('_protocol', None)
newargs['_environ'] = self.environ
url = self.mapper.generate(*route_args, **newargs)
if anchor is not None:
url += '#' + _url_quote(anchor, encoding)
- if host or protocol or qualified:
+ if host or (protocol is not None) or qualified:
if 'routes.cached_hostinfo' not in self.environ:
cache_hostinfo(self.environ)
hostinfo = self.environ['routes.cached_hostinfo']
@@ -412,12 +424,14 @@ class URLGenerator(object):
host = hostinfo['host'].split(':')[0]
elif not host:
host = hostinfo['host']
- if not protocol:
+ if protocol is None:
protocol = hostinfo['protocol']
+ if protocol != '':
+ protocol += ':'
if url is not None:
if host[-1] != '/':
host += '/'
- url = protocol + '://' + host + url.lstrip('/')
+ url = protocol + '//' + host + url.lstrip('/')
if not ascii_characters(url) and url is not None:
raise GenerationException("Can only return a string, got "
diff --git a/setup.py b/setup.py
index 81d2877..0854eb8 100644
--- a/setup.py
+++ b/setup.py
@@ -1,4 +1,4 @@
-__version__ = '2.2'
+__version__ = '2.3.1'
import io
import os
@@ -41,7 +41,8 @@ setup(name="Routes",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.2",
"Programming Language :: Python :: 3.3",
- "Programming Language :: Python :: 3.4"
+ "Programming Language :: Python :: 3.4",
+ "Programming Language :: Python :: 3.5"
],
keywords='routes webob dispatch',
author="Ben Bangert",
@@ -56,5 +57,10 @@ setup(name="Routes",
"six",
"repoze.lru>=0.3"
],
+ extras_require={
+ 'middleware': [
+ 'webob',
+ ]
+ },
**extra_options
)
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/routes.git
More information about the Python-modules-commits
mailing list