Changeset 80


Ignore:
Timestamp:
12/30/10 00:06:57 (13 years ago)
Author:
atzm
Message:

change API spec

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pycgibattler/trunk/index.cgi

    r78 r80  
    251251 
    252252    if 'mode' in form and form.getfirst('mode') == 'json': 
    253         if 'id' in form: 
    254             data = {} 
    255             ids = form['id'] 
    256  
    257             if type(ids) is not list: 
    258                 ids = [ids] 
    259  
    260             if len(ids) > CONFIG.getint('battle', 'max_entries'): 
    261                 return jsondump({'result': {}}) 
    262  
    263             try: 
    264                 for id_ in ids: 
    265                     data[id_.value] = CharacterManager(id_.value).flatten() 
    266             except: 
    267                 return jsondump({'result': {}}) 
    268  
    269             return jsondump({'result': data}) 
    270  
    271         return jsondump({'result': [cm.id() for cm in CharacterManager.list()]}) 
     253        if 'id' not in form: 
     254            ids = [cm.id() for cm in CharacterManager.list()] 
     255        else: 
     256            tmp = form['id'] 
     257            if type(tmp) is not list: 
     258                tmp = [form['id']] 
     259            ids = [id_.value for id_ in tmp] 
     260 
     261        data = {} 
     262        try: 
     263            for id_ in ids: 
     264                data[id_] = CharacterManager(id_).flatten() 
     265        except: 
     266            return jsondump({'result': {}}) 
     267        return jsondump({'result': data}) 
    272268 
    273269    if 'id' in form: 
Note: See TracChangeset for help on using the changeset viewer.