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
14 from mod_python import apache
16 from PLC.Debug import log
18 from PLC.API import PLCAPI
23 if req.method != "POST":
24 req.content_type = "text/html"
25 req.send_http_header()
28 <title>PLCAPI XML-RPC/SOAP Interface</title>
30 <h1>PLCAPI XML-RPC/SOAP Interface</h1>
31 <p>Please use XML-RPC or SOAP to access the PLCAPI.</p>
37 request = req.read(int(req.headers_in['content-length']))
39 # mod_python < 3.2: The IP address portion of remote_addr is
40 # incorrect (always 0.0.0.0) when IPv6 is enabled.
41 # http://issues.apache.org/jira/browse/MODPYTHON-64?page=all
42 (remote_ip, remote_port) = req.connection.remote_addr
43 remote_addr = (req.connection.remote_ip, remote_port)
46 response = api.handle(remote_addr, request)
49 req.content_type = "text/xml"
50 req.headers_out.add("Content-length", str(len(response)))
51 req.send_http_header()
57 # Log error in /var/log/httpd/(ssl_)?error_log
58 print >> log, traceback.format_exc()
59 return apache.HTTP_INTERNAL_SERVER_ERROR