diff options
author | Ben Bangert <ben@groovie.org> | 2010-02-20 16:38:02 -0500 |
---|---|---|
committer | Ben Bangert <ben@groovie.org> | 2010-02-20 16:38:02 -0500 |
commit | 179638a726241282039ad7759b68c3c7c2693d91 (patch) | |
tree | cc921cae29e471d22275384f4f557e887e625d7a /routes | |
parent | d397ec29303319e71fd4546e7eadcdb2a885ebcf (diff) | |
download | routes-179638a726241282039ad7759b68c3c7c2693d91.tar.gz |
More tests, coverage
--HG--
branch : trunk
Diffstat (limited to 'routes')
-rw-r--r-- | routes/middleware.py | 18 | ||||
-rw-r--r-- | routes/util.py | 9 |
2 files changed, 7 insertions, 20 deletions
diff --git a/routes/middleware.py b/routes/middleware.py index 52b684b..6c22ff6 100644 --- a/routes/middleware.py +++ b/routes/middleware.py @@ -2,10 +2,7 @@ import re import logging -try: - from webob import Request -except: - pass +from webob import Request from routes.base import request_config from routes.util import URLGenerator, url_for @@ -45,9 +42,6 @@ class RoutesMiddleware(object): def __call__(self, environ, start_response): """Resolves the URL in PATH_INFO, and uses wsgi.routing_args to pass on URL resolver results.""" - config = request_config() - config.mapper = self.mapper - old_method = None if self.use_method_override: req = None @@ -79,10 +73,11 @@ class RoutesMiddleware(object): # Run the actual route matching # -- Assignment of environ to config triggers route matching - config.environ = environ - - match = config.mapper_dict - route = config.route + results = self.mapper.routematch(environ=environ) + if results: + match, route = results[0], results[1] + else: + match = route = None if old_method: environ['REQUEST_METHOD'] = old_method @@ -131,7 +126,6 @@ class RoutesMiddleware(object): # Wrapped in try as in rare cases the attribute will be gone already try: - del config.environ del self.mapper.environ except AttributeError: pass diff --git a/routes/util.py b/routes/util.py index 601d742..f56e9ab 100644 --- a/routes/util.py +++ b/routes/util.py @@ -77,14 +77,7 @@ def _subdomain_check(kargs, mapper, environ): if isinstance(subdomain, unicode): subdomain = str(subdomain) - # We use a try/except here, cause the only time there should be no - # environ is when we're unit testing, in which case we shouldn't be - # changing kargs and such. The exception catching also won't hurt as - # badly here vs doing a hasattr on every url check - try: - fullhost = environ.get('HTTP_HOST') or environ.get('SERVER_NAME') - except AttributeError: - return kargs + fullhost = environ.get('HTTP_HOST') or environ.get('SERVER_NAME') # In case environ defaulted to {} if not fullhost: |