コード例 #1
0
ファイル: api.py プロジェクト: SuperKablamo/superlarp-sk
 def post(self):
     """Creates a new Player Character.
     """
     _trace = TRACE + "APICreatePlayerCharacters:: post() "
     logging.info(_trace)
     user = self.get_user()
     if user is None:
         r = API404
         r[MSG] = "User not found."
         return self.response.out.write(simplejson.dumps(r))
     key = self.request.get("key")
     logging.info(_trace + "key = " + key)
     template = db.get(key)
     if template is not None:
         try:
             name = self.request.get("name")
         except AttributeError:
             r = API400
             r[MSG] = "Missing 'name' parameter."
             return self.response.out.write(simplejson.dumps(r))
         logging.info(_trace + "name = " + name)
         player = character.createPlayerFromTemplate(template, name, user)
         r = API201
         r[MSG] = "Fortune favors the bold!"
         r[player.class_name()] = character.getJSONPlayer(player)
     else:
         r = API404
         r[MSG] = "Template not found for key " + key + " ."
     return self.response.out.write(simplejson.dumps(r))
コード例 #2
0
ファイル: api.py プロジェクト: SuperKablamo/d20m-morningstar
 def post(self):
     '''Creates a new Player Character.
     '''
     _trace = TRACE+'APICreatePlayerCharacters:: post() '
     logging.info(_trace)        
     user = self.get_user()
     if user is None:
         r = API404
         r[MSG] = 'User not found.'
         return self.response.out.write(simplejson.dumps(r))            
     key = self.request.get('key')
     logging.info(_trace+'key = '+key)  
     template = db.get(key)
     if template is not None:
         try:
             name = self.request.get('name')
         except AttributeError:
             r = API400
             r[MSG] = 'Missing \'name\' parameter.' 
             return self.response.out.write(simplejson.dumps(r))                     
         logging.info(_trace+'name = '+name)                           
         player = character.createPlayerFromTemplate(template, name, user)
         r = API201
         r[MSG] = 'Fortune favors the bold!'
         r[player.class_name()] = character.getJSONPlayer(player)
     else:    
         r = API404
         r[MSG] = 'Template not found for key '+key+' .'        
     return self.response.out.write(simplejson.dumps(r)) 
コード例 #3
0
 def post(self):  
     _trace = TRACE+'CharacterHandler.post() '
     logging.info(_trace)
     user = users.get_current_user()
     key = self.request.get('template')
     name = self.request.get('name')
     template = db.get(key)
     if template is not None:
         _player = character.createPlayerFromTemplate(template, name, user)
         lat = self.request.get('lat')
         lon = self.request.get('lon')
         location = db.GeoPt(utils.strToIntOrFloat(lat), 
                             utils.strToIntOrFloat(lon))
         
         _party = party.createJSONParty(_player, location)            
         
     self.redirect('/mobile/character/'+str(_player.key()))