Show
Ignore:
Timestamp:
03/10/10 12:32:00 (6 months ago)
Author:
acracia
Branch:
default
Message:

[api]to_dict method on the model, tailored to use as input of the api

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • pdw/model/frbr.py

    r325 r326  
    302302        out_obj.items = items 
    303303        return out_obj 
     304 
    304305    def to_dict(self): 
     306        ''' 
     307        create a dict equivalent to the dict the api is receiving 
     308        ''' 
    305309        out_dict = {} 
    306310        table = orm.class_mapper(self.__class__).mapped_table 
     
    310314            out_dict[col.name] = val 
    311315            # TODO: check type ... 
     316        persons = [] 
    312317        if self.persons: 
    313             persons = [] 
    314318            for person in self.persons: 
     319                #TO DO: change this for a consult to the person table, to get 
     320                #the attrs the person has 
    315321                oneperson = {'name': person.name, 
    316322                             'birth_date': person.birth_date, 
    317323                             'death_date': person.death_date, 
    318                              'type': person.type, 
    319                              'country': person.country,} 
     324                             'type': person.entity_type, 
     325                             } 
    320326                persons.append(oneperson) 
    321327            out_dict['persons'] = persons 
    322  
    323  
    324328        return out_dict 
    325  
    326  
    327329 
    328330