I am developing a python app for my raspberry. The aim of this piece of software is to listen POST from another software, when I get the POST I want to send a message through a zigbee module attached to the raspberry.
My problem is that how I have implemented the web server for the raspberry in python, I am not able to access the class that is able to send the message through zigbee.
[Update] To make it more clear, my problem is that I cant access to wsanProtocol in the do_POST method. So I can't use my interface for xbee.
Could you give me any ideas on how to do it?
Here is the code of my webserver:
class webServer(threading.Thread):    
    def __init__(self, serverAddress, port, wsanProtocol):
        self.wsanProtocol = wsanProtocol
        self.serverAddress = serverAddress
    self.port = port
    self.serverRunning = True
        threading.Thread.__init__(self)
    def run(self):
        server_class = BaseHTTPServer.HTTPServer        
        httpd = server_class((self.serverAddress, self.port), MyHandler)
        print time.asctime(), "Server Starts - %s:%s" % (self.serverAddress, self.port)
        try:
            httpd.serve_forever()
        except KeyboardInterrupt:
            pass
        httpd.server_close()
        print time.asctime(), "Server Stops - %s:%s" % (HOST_NAME, PORT_NUMBER)
class MyHandler(BaseHTTPServer.BaseHTTPRequestHandler):
    def do_HEAD(s):
        s.send_response(200)
        s.send_header("Content-type", "text/html")
        s.end_headers()
    def do_GET(s):
        """Respond to a GET request."""
        if None != re.search('api/v1/nodo/*', s.path):
            nodeID = s.path.split('/')[-1]
            print 'Solicitando informacion del nodo '+nodeID
            s.send_response(200)
            s.send_header("Content-type", "text/html")
            s.end_headers()
            #Prepare JSON with node information        
            #jsonnode = json.dumps(nodeOjbect.__dict__)
            jsonnode = '{ "mac":'+nodeID+', "bat":4.0 }'
            s.wfile.write(jsonnode)        
        if None != re.search('api/v1/st_act/*', s.path):
            nodeID = s.path.split('/')[-1]
            print 'Solicitando informacion del actuador '+nodeID
            s.send_response(200)
            s.send_header("Content-type", "text/html")
            s.end_headers()
            #Prepare JSON with node information        
            #jsonnode = json.dumps(nodeOjbect.__dict__)
            jsonnode = '{ "mac":'+nodeID+', "status":"off" }'
            s.wfile.write(jsonnode)
    def do_POST(self):
        print "ejecutando POST"
        if None != re.search('api/v1/act/*', self.path):
            ctype, pdict = cgi.parse_header(self.headers.getheader('content-type'))
            if ctype == 'application/json':
                length = int(self.headers.getheader('content-length'))
                data = cgi.parse_qs(self.rfile.read(length), keep_blank_values=1)
                print data
                req = json.loads(data.keys()[0])
                resCommand = None
                #Cant get access to my wsanProtocol!!
                #webServer.wsanProtocol.executeCommand(10, resCommand, req.tolist())
                print 'Actuacion sobre el nodo ' + req["mac"]
                self.send_response(200)
Thank you very much!
 
    