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
14 from sfa.util.debug import log
15 from sfa.plc.api import GeniAPI
17 api = GeniAPI(interface='registry')
21 Write to /var/log/httpd/error_log. See
\r
23 http://www.modpython.org/FAQ/faqw.py?req=edit&file=faq02.003.htp
\r
26 def write(self, data):
\r
27 sys.stderr.write(data)
\r
34 if req.method != "POST":
35 req.content_type = "text/html"
36 req.send_http_header()
39 <title>SFA Registry API XML-RPC/SOAP Interface</title>
41 <h1>SFA Registry API XML-RPC/SOAP Interface</h1>
42 <p>Please use XML-RPC or SOAP to access the SFA API.</p>
48 request = req.read(int(req.headers_in['content-length']))
50 # mod_python < 3.2: The IP address portion of remote_addr is
51 # incorrect (always 0.0.0.0) when IPv6 is enabled.
52 # http://issues.apache.org/jira/browse/MODPYTHON-64?page=all
53 (remote_ip, remote_port) = req.connection.remote_addr
54 remote_addr = (req.connection.remote_ip, remote_port)
57 response = api.handle(remote_addr, request)
60 req.content_type = "text/xml; charset=" + api.encoding
61 req.send_http_header()
66 except Exception, err:
67 # Log error in /var/log/httpd/(ssl_)?error_log
68 print >> log, err, traceback.format_exc()
69 return apache.HTTP_INTERNAL_SERVER_ERROR