[ create a new paste ] login | about

Project: circuits
Link: http://circuits.codepad.org/koheHUSq    [ raw code | output | fork ]

Python, pasted on Jan 11:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
	def index(self, name=None, content=None):
		"""Grab a file from gridfs, set the appropriate content-type header
		and dump it to circuits.web for the rest.
		"""
		# Incorrect/incomplete data, redirect to /
		if name is None or content is None:
			return self.redirect("/")
			
		# Set Content-Type header
		self.response.headers["Content-Type"] = contentmap[content]
		
		# Get the file, redirect to / if it doesnt exist
		data = self.env.db.filenames.find_one({"name": name})
		if not data:
			return self.redirect("/")
		f = self.env.gridfs.get(data["id"])
		
		# Dump it
		return f.read()


Output:
1
2
3
4
  Line 1
    def index(self, name=None, content=None):
    ^
IndentationError: unexpected indent


Create a new paste based on this one


Comments: