Merge branch 'pecan-env' of github.com:pecan/pecan into pecan/pecan-env
* 'pecan-env' of github.com:pecan/pecan: update to guess_type on full path updated ext test to use None content_type
This commit is contained in:
@@ -111,9 +111,6 @@ class Pecan(object):
|
||||
self.template_path = template_path
|
||||
self.force_canonical = force_canonical
|
||||
|
||||
def get_content_type(self, format):
|
||||
return guess_type(format)[0]
|
||||
|
||||
def route(self, node, path):
|
||||
path = path.split('/')[1:]
|
||||
try:
|
||||
@@ -247,10 +244,10 @@ class Pecan(object):
|
||||
path = request.pecan['routing_path']
|
||||
|
||||
if not request.pecan['content_type'] and '.' in path.split('/')[-1]:
|
||||
path, format = os.path.splitext(path)
|
||||
request.pecan['content_type'] = guess_type(path)[0]
|
||||
# store the extension for retrieval by controllers
|
||||
path, format = os.path.splitext(path)
|
||||
request.pecan['extension'] = format
|
||||
request.pecan['content_type'] = self.get_content_type(format)
|
||||
controller, remainder = self.route(self.root, path)
|
||||
cfg = _cfg(controller)
|
||||
|
||||
@@ -323,7 +320,7 @@ class Pecan(object):
|
||||
# if there is a template, render it
|
||||
if template:
|
||||
if template == 'json':
|
||||
request.pecan['content_type'] = self.get_content_type('.json')
|
||||
request.pecan['content_type'] = 'application/json'
|
||||
result = self.render(template, result)
|
||||
|
||||
# pass the response through htmlfill (items are popped out of the
|
||||
|
||||
@@ -519,7 +519,7 @@ class TestBase(TestCase):
|
||||
Test extension splits
|
||||
"""
|
||||
class RootController(object):
|
||||
@expose()
|
||||
@expose(content_type=None)
|
||||
def _default(self, *args):
|
||||
from pecan.core import request
|
||||
return request.pecan['extension']
|
||||
|
||||
Reference in New Issue
Block a user