示例#1
0
	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
示例#2
0
def handler(req):
	"""
	Handles mod_python main request handler.
	
	Returns page as provided by BaseController or SpecialController
	(if one exists for given controller= provided with the GET method)
	"""

	logger.start('New request',reset=True)
	logger.show('ip: %s' % req.connection.remote_ip)
	logger.show('uri: %s' % req.unparsed_uri)
	req.get_options()['mod_python.dbm_session.database_directory'] = getTempPath()
	req.get_options()['mod_python.session.cookie_name'] = getInstanceId()

	flush = True
	try: ret, flush = handleRequest(req)
	except:
		# force log fush and raise
		logger.flush()
		raise
	logger.end(close=flush)
	return ret