Пример #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
 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")