コード例 #1
0
ファイル: statmonControllers.py プロジェクト: palli/statmon
	def handleRequest(self):
		Grapher,params = decodeGraph(self.getField('p'))
		if not Grapher:
			return apache.HTTP_INTERNAL_SERVER_ERROR

		for key,value in {
			'db' : model.getDB(),
			'datapath' : '%s/' % getTempPath('data'),
			'imagepath' : '%s/' % getTempPath('images'),
			'logger' : logger,
			'graph' : False,
			'maxage': 600,
			'hidetitle' : True,
			'graph' : True,
		}.items(): params[key] = value

		graph = Grapher(**params)

		filename = graph.getFullPathImagename()

		self.req.content_type = {
			'png' : 'image/png',
			'svg' : 'image/svg+xml',
			'eps' : 'application/postscript',
			'pdf' : 'application/pdf',
		}[graph.format.lower()]	

		if not os.path.exists(filename):
			raise apache.SERVER_RETURN, apache.HTTP_NOT_FOUND
		self.req.sendfile(filename)

		return apache.OK