def Execute(self,conn,request):
        """The method that handles all the commands, and routes them to the correct method for that stage."""
        # New request or old?
        try:
            session = request.getTagAttr('command','sessionid')
        except:
            session = None
        try:
            action = request.getTagAttr('command','action')
        except:
            action = None
        if action == None: action = 'execute'
        # Check session is in session list
        if self.sessions.has_key(session):
            if self.sessions[session]['jid']==request.getFrom():
                # Check action is vaild
                if self.sessions[session]['actions'].has_key(action):
                    # Execute next action
                    self.sessions[session]['actions'][action](conn,request)
                else:
                    # Stage not presented as an option
                    self._owner.send(Error(request,ERR_BAD_REQUEST))
                    raise NodeProcessed
            else:
                # Jid and session don't match. Go away imposter
                self._owner.send(Error(request,ERR_BAD_REQUEST))
                raise NodeProcessed
        elif session != None:
            # Not on this sessionid you won't.
            self._owner.send(Error(request,ERR_BAD_REQUEST))
            raise NodeProcessed
        else:
            # New session
            self.initial[action](conn,request)
The method that handles all the commands, and routes them to the correct method for that stage.
chrome-cordova/gcmServer/xmpp/commands.py