Ejemplo n.º 1
0
 def put(self, key):
     '''Adds a Character to a Party.
     '''
     _trace = TRACE+'APIParties:: put() '
     logging.info(_trace)        
     _party = db.get(key)        
     if _party is not None and _party.class_name() == 'Party':
         try:
             character_key = self.request.get('character_key')
         except AttributeError:
             r = API400
             r[MSG] = 'Missing \'character_key\' parameter.'
         
         character = db.get(character_key)
         if character is not None and character.class_name() == 'Character':
             _party = party.updateJSONParty(party, character)
             r = API200
             r[MSG] = 'The party grows stronger!'
             r[_party.class_name()] = _party
         else:
               r = API404
               r[MSG] = 'Character not found for key '+character_key+' .'                  
         
         r = API200
         r[MSG] = 'Adventure a party makes.'
         r[_party.class_name()] = party.getJSONParty(party)
     else:
         r = API404
         r[MSG] = 'Party not found for key '+key+' .'  
           
     return self.response.out.write(simplejson.dumps(r))
Ejemplo n.º 2
0
    def put(self, key):
        """Adds a Character to a Party.
        """
        _trace = TRACE + "APIParties:: put() "
        logging.info(_trace)
        _party = db.get(key)
        if _party is not None and _party.class_name() == "Party":
            try:
                character_key = self.request.get("character_key")
            except AttributeError:
                r = API400
                r[MSG] = "Missing 'character_key' parameter."

            character = db.get(character_key)
            if character is not None and character.class_name() == "Character":
                _party = party.updateJSONParty(party, character)
                r = API200
                r[MSG] = "The party grows stronger!"
                r[_party.class_name()] = _party
            else:
                r = API404
                r[MSG] = "Character not found for key " + character_key + " ."

            r = API200
            r[MSG] = "Adventure a party makes."
            r[_party.class_name()] = party.getJSONParty(party)
        else:
            r = API404
            r[MSG] = "Party not found for key " + key + " ."

        return self.response.out.write(simplejson.dumps(r))
Ejemplo n.º 3
0
 def post(self):
     '''Creates and Returns a new Party.
     '''
     _trace = TRACE+'APICreateParties:: post() '
     logging.info(_trace)       
     key = self.request.get('key')
     lat = self.request.get('lat')
     lon = self.request.get('lon')
     if key is None:
         r = API400
         r[MSG] = 'Missing \'key\' parameter.'
     if lat is None:
         r = API400
         r[MSG] = 'Missing \'lat\' parameter.'
     if lon is None:
         r = API400
         r[MSG] = 'Missing \'lon\' parameter.'                        
     logging.info(_trace+'key ='+key)    
     logging.info(_trace+'lat = '+lat)    
     logging.info(_trace+'lon ='+lon)                    
     character = db.get(str(key))
     if character is not None or character.class_name() == 'Character':
         location = db.GeoPt(lat, lon)
         _party = party.createJSONParty(character, location)
         r = API201
         r[MSG] = 'It is gold and adventure you seek?'
         r['PlayerParty'] = _party
     else:
         r = API404
         r[MSG] = 'Character not found for key '+key+' .'
             
     return self.response.out.write(simplejson.dumps(r)) 
Ejemplo n.º 4
0
    def post(self):
        """Creates and Returns a new Party.
        """
        _trace = TRACE + "APICreateParties:: post() "
        logging.info(_trace)
        key = self.request.get("key")
        lat = self.request.get("lat")
        lon = self.request.get("lon")
        if key is None:
            r = API400
            r[MSG] = "Missing 'key' parameter."
        if lat is None:
            r = API400
            r[MSG] = "Missing 'lat' parameter."
        if lon is None:
            r = API400
            r[MSG] = "Missing 'lon' parameter."
        logging.info(_trace + "key =" + key)
        logging.info(_trace + "lat = " + lat)
        logging.info(_trace + "lon =" + lon)
        character = db.get(str(key))
        if character is not None or character.class_name() == "Character":
            location = db.GeoPt(lat, lon)
            _party = party.createJSONParty(character, location)
            r = API201
            r[MSG] = "It is gold and adventure you seek?"
            r["PlayerParty"] = _party
        else:
            r = API404
            r[MSG] = "Character not found for key " + key + " ."

        return self.response.out.write(simplejson.dumps(r))
Ejemplo n.º 5
0
 def delete(self, key):
     '''Deletes a NonPlayerCharacter. 
     '''
     _trace = TRACE+'APINonPlayerCharacters:: delete() '
     logging.info(_trace)        
     character = db.get(key) 
     if character is not None and character.class_name() == 'Character':
         character.delete()
         r = API200
         r[MSG] = 'The world is a better place now that this one is gone.'
     else:
         r = API404
         r[MSG] = 'NonPlayerCharacter not found for key '+key+' .'              
     return self.response.out.write(simplejson.dumps(r))
Ejemplo n.º 6
0
 def delete(self, key):
     '''Deletes a PlayerCharacter. 
     '''
     _trace = TRACE+'APIPlayerCharacters:: delete() '
     logging.info(_trace)        
     character = db.get(key) 
     if character is not None and character.class_name() == 'Character':
         character.delete()
         r = API200
         r[MSG] = 'The funeral pyre burns bright.'
     else:
         r = API404
         r[MSG] = 'PlayerCharacter not found for key '+key+' .'        
     return self.response.out.write(simplejson.dumps(r))
Ejemplo n.º 7
0
 def delete(self, key):
     """Deletes a NonPlayerCharacter. 
     """
     _trace = TRACE + "APINonPlayerCharacters:: delete() "
     logging.info(_trace)
     character = db.get(key)
     if character is not None and character.class_name() == "Character":
         character.delete()
         r = API200
         r[MSG] = "The world is a better place now that this one is gone."
     else:
         r = API404
         r[MSG] = "NonPlayerCharacter not found for key " + key + " ."
     return self.response.out.write(simplejson.dumps(r))
Ejemplo n.º 8
0
 def delete(self, key):
     """Deletes a PlayerCharacter. 
     """
     _trace = TRACE + "APIPlayerCharacters:: delete() "
     logging.info(_trace)
     character = db.get(key)
     if character is not None and character.class_name() == "Character":
         character.delete()
         r = API200
         r[MSG] = "The funeral pyre burns bright."
     else:
         r = API404
         r[MSG] = "PlayerCharacter not found for key " + key + " ."
     return self.response.out.write(simplejson.dumps(r))