'The method that handles all the commands, and routes them to the correct method for that stage.'

def Execute(self, conn, request):

    try:
        session = request.getTagAttr('command', 'sessionid')
    except:
        session = None
    try:
        action = request.getTagAttr('command', 'action')
    except:
        action = None
    if (action == None):
        action = 'execute'
    if self.sessions.has_key(session):
        if (self.sessions[session]['jid'] == request.getFrom()):
            if self.sessions[session]['actions'].has_key(action):
                self.sessions[session]['actions'][action](conn, request)
            else:
                self._owner.send(Error(request, ERR_BAD_REQUEST))
                raise NodeProcessed
        else:
            self._owner.send(Error(request, ERR_BAD_REQUEST))
            raise NodeProcessed
    elif (session != None):
        self._owner.send(Error(request, ERR_BAD_REQUEST))
        raise NodeProcessed
    else:
        self.initial[action](conn, request)
