File: bottle.py

package info (click to toggle)
python-flask-rdf 0.2.0-1.1~deb9u1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 132 kB
  • sloc: python: 312; makefile: 14
file content (30 lines) | stat: -rw-r--r-- 693 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
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
		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)