예제 #1
0
 def _content_type_from_accept(self):
     """
     Given a requested format this method determines the content-type
     to set and the genshi template loader to use in order to render
     it accurately.  TextTemplate must be used for non-xml templates
     whilst all that are some sort of XML should use MarkupTemplate.
     """
     ct, mu, ext = accept.parse_header(request.headers.get("Accept", ""))
     return ct, ext, (NewTextTemplate, MarkupTemplate)[mu]
예제 #2
0
파일: package.py 프로젝트: abulte/ckan
 def _content_type_from_accept(self):
     """
     Given a requested format this method determines the content-type
     to set and the genshi template loader to use in order to render
     it accurately.  TextTemplate must be used for non-xml templates
     whilst all that are some sort of XML should use MarkupTemplate.
     """
     ct, mu, ext = accept.parse_header(request.headers.get('Accept', ''))
     return ct, ext, (NewTextTemplate, MarkupTemplate)[mu]
예제 #3
0
 def test_accept_invalid(self):
     ct, ext = accept.parse_header(None)
     assert_equal(ct, "text/html; charset=utf-8")
     assert_equal(ext, "html")
예제 #4
0
 def test_accept_valid6(self):
     a = "application/rdf+xml;q=0.9,application/xhtml+xml,text/html;q=0.5"
     ct, ext = accept.parse_header(a)
     assert_equal(ct, "application/rdf+xml; charset=utf-8")
     assert_equal(ext, "rdf")
예제 #5
0
 def test_accept_valid4(self):
     a = "application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5"
     ct, ext = accept.parse_header(a)
     assert_equal(ct, "text/html; charset=utf-8")
     assert_equal(ext, "html")
예제 #6
0
 def test_accept_valid2(self):
     a = "text/turtle,application/turtle,application/rdf+xml;q=0.9,text/plain;q=0.8,*/*;q=.5"
     ct, ext = accept.parse_header(a)
     assert_equal(ct, "application/rdf+xml; charset=utf-8")
     assert_equal(ext, "rdf")
예제 #7
0
 def test_accept_valid7(self):
     a = "text/turtle,application/turtle,application/rdf+xml;q=0.8,text/plain;q=0.9,*/*;q=.5"
     ct, markup, ext = accept.parse_header(a)
     assert_equal(ct, "text/plain; charset=utf-8")
     assert_equal(markup, False)
     assert_equal(ext, "txt")
예제 #8
0
 def test_accept_invalid3(self):
     ct, markup, ext = accept.parse_header("wombles")
     assert_equal(ct, "text/html; charset=utf-8")
     assert_equal(markup, True)
     assert_equal(ext, "html")
예제 #9
0
 def test_accept_valid5(self):
     a = "application/rdf+xml;q=0.5,application/xhtml+xml,text/html;q=0.9"
     ct, markup, ext = accept.parse_header(a)
     assert_equal(ct, "text/html; charset=utf-8")
     assert_equal(markup, True)
     assert_equal(ext, "html")
예제 #10
0
 def test_accept_valid6(self):
     a = "application/rdf+xml;q=0.9,application/xhtml+xml,text/html;q=0.5"
     ct, markup, ext = accept.parse_header(a)
     assert_equal( ct, "application/rdf+xml; charset=utf-8")
     assert_equal( markup, True)
     assert_equal( ext, "rdf")
예제 #11
0
 def test_accept_valid7(self):
     a = "text/turtle,application/turtle,application/rdf+xml;q=0.8,text/plain;q=0.9,*/*;q=.5"
     ct, markup, ext = accept.parse_header(a)
     assert_equal( ct, "text/plain; charset=utf-8")
     assert_equal( markup, False)
     assert_equal( ext, "txt")
예제 #12
0
 def test_accept_invalid(self):
     ct, markup, ext = accept.parse_header(None)
     assert_equal( ct, "text/html; charset=utf-8")
     assert_equal( markup, True)
     assert_equal( ext, "html")
예제 #13
0
 def test_accept_valid4(self):
     a = "application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5"
     ct, markup, ext = accept.parse_header(a)
     assert_equal( ct, "text/html; charset=utf-8")
     assert_equal( markup, True)
     assert_equal( ext, "html")
예제 #14
0
 def test_accept_valid(self):
     a = "text/turtle,application/turtle,application/rdf+xml,text/plain;q=0.8,*/*;q=.5"
     ct, markup, ext = accept.parse_header(a)
     assert_equal( ct, "application/rdf+xml; charset=utf-8")
     assert_equal( markup, True)
     assert_equal( ext, "rdf")
예제 #15
0
 def test_accept_valid5(self):
     a = "application/rdf+xml;q=0.5,application/xhtml+xml,text/html;q=0.9"
     ct, ext = accept.parse_header(a)
     assert_equal( ct, "text/html; charset=utf-8")
     assert_equal( ext, "html")
예제 #16
0
 def test_accept_invalid3(self):
     ct, ext = accept.parse_header("wombles")
     assert_equal( ct, "text/html; charset=utf-8")
     assert_equal( ext, "html")