2 # Apache mod_python interface
4 # Aaron Klingaman <alk@absarokasoft.com>
5 # Mark Huang <mlhuang@cs.princeton.edu>
7 # Copyright (C) 2004-2006 The Trustees of Princeton University
13 from mod_python import apache
15 from sfa.plc.api import SfaAPI
16 from sfa.util.debug import log
18 api = SfaAPI(interface='aggregate')
22 Write to /var/log/httpd/error_log. See
\r
24 http://www.modpython.org/FAQ/faqw.py?req=edit&file=faq02.003.htp
\r
27 def write(self, data):
\r
28 sys.stderr.write(data)
\r
35 if req.method != "POST":
36 req.content_type = "text/html"
37 req.send_http_header()
40 <title>SFA Aggregate API XML-RPC/SOAP Interface</title>
42 <h1>SFA Aggregate API XML-RPC/SOAP Interface</h1>
43 <p>Please use XML-RPC or SOAP to access the SFA API.</p>
49 request = req.read(int(req.headers_in['content-length']))
51 # mod_python < 3.2: The IP address portion of remote_addr is
52 # incorrect (always 0.0.0.0) when IPv6 is enabled.
53 # http://issues.apache.org/jira/browse/MODPYTHON-64?page=all
54 (remote_ip, remote_port) = req.connection.remote_addr
55 remote_addr = (req.connection.remote_ip, remote_port)
58 response = api.handle(remote_addr, request)
61 req.content_type = "text/xml; charset=" + api.encoding
62 req.send_http_header()
67 except Exception, err:
68 # Log error in /var/log/httpd/(ssl_)?error_log
69 print >> log, err, traceback.format_exc()
70 return apache.HTTP_INTERNAL_SERVER_ERROR