Skip to content

Commit

Permalink
Merge pull request #433 from gratipay/issue431
Browse files Browse the repository at this point in the history
fix for #431
  • Loading branch information
Changaco committed Jun 4, 2015
2 parents 8da0b56 + 03bf982 commit dd6aa03
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
6 changes: 5 additions & 1 deletion aspen/resources/simplate.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,12 +230,16 @@ def _unbound_parse_specline(self, specline):

#Assign parts
media_type, renderer = parts
if media_type == '':
# no media type specified, use the default
media_type = self.media_type
if renderer == '':
# no renderer specified, use the default
renderer = self.website.default_renderers_by_media_type[media_type]

# Validate media type.
if media_type_re.match(media_type) is None:
msg = ("Malformed media type %s in specline %s. It must match "
msg = ("Malformed media type '%s' in specline '%s'. It must match "
"%s.")
msg %= (media_type, specline, media_type_re.pattern)
raise SyntaxError(msg)
Expand Down
10 changes: 10 additions & 0 deletions tests/test_simplates.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@
from __future__ import unicode_literals



def test_default_media_type_works(harness):
harness.fs.www.mk(('index.spt', """
[---]
[---]
plaintext"""))
response = harness.client.GET(raise_immediately=False)
assert "plaintext" in response.body


def test_can_use_request_headers(harness):
response = harness.simple( "foo = request.headers['Foo']\n"
"[-----] via stdlib_format\n"
Expand Down

0 comments on commit dd6aa03

Please sign in to comment.