Always include `pecan.request['extension']`.

This commit is contained in:
Ryan Petrello
2013-01-08 12:30:08 -05:00
parent dae522f2a6
commit 1dd90ca058
2 changed files with 3 additions and 2 deletions

View File

@@ -368,6 +368,7 @@ class Pecan(object):
# lookup the controller, respecting content-type as requested
# by the file extension on the URI
path = request.pecan['routing_path']
request.pecan['extension'] = None
# attempt to guess the content type based on the file extension
if not request.pecan['content_type'] and '.' in path.split('/')[-1]:

View File

@@ -863,7 +863,7 @@ class TestFileTypeExtensions(unittest.TestCase):
class RootController(object):
@expose(content_type=None)
def _default(self, *args):
ext = request.pecan.get('extension')
ext = request.pecan['extension']
assert len(args) == 1
if ext:
assert ext not in args[0]
@@ -916,7 +916,7 @@ class TestFileTypeExtensions(unittest.TestCase):
@expose(content_type=None)
def _default(self, *args):
assert 'example:x.tiny' in args
assert 'extension' not in request.pecan
assert request.pecan['extension'] is None
return 'SOME VALUE'
app = TestApp(Pecan(RootController()))