File: bottle.py

package info (click to toggle)
python-flask-rdf 0.2.1-1%2Bdeb10u1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 132 kB
  • sloc: python: 323; makefile: 14
file content (31 lines) | stat: -rw-r--r-- 740 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
from __future__ import absolute_import
from .common_decorators import ViewDecorator
from rdflib.graph import Graph


class Decorator(ViewDecorator):
	@classmethod
	def make_new_response(cls, old_response, mimetype, serialized):
		import bottle
		bottle.response.content_type = mimetype
		bottle.response.set_header('Vary', 'Accept')
		return serialized

	@classmethod
	def make_406_response(cls):
		import bottle
		bottle.abort(406, '406 Not Acceptable')

	@classmethod
	def get_accept(cls):
		import bottle
		return bottle.request.headers.get('Accept', '')


_implicit_instance = Decorator()


def output(output, accepts):
	return _implicit_instance.output(output, accepts)
def returns_rdf(view):
	return _implicit_instance.decorate(view)