Example #1
0
def to_rest(entity):
    """ Full serialization of the entity. """
    data = to_rest_base(entity)
    data['created_at'] = entity.created_at
    data['updated_at'] = entity.updated_at

    ss = [schemata_logic.to_rest_index(s) for s in entity.schemata]
    data['schemata'] = ss

    data['properties'] = {}
    for prop in entity.active_properties:
        name, prop = properties_logic.to_rest(prop)
        data['properties'][name] = prop

    data['inbound_relations'] = entity.inbound.count()
    if data['inbound_relations'] > 0:
        data['inbound_url'] = url_for('relations_api.index', target=entity.id)
    
    data['outbound_relations'] = entity.outbound.count()
    if data['outbound_relations'] > 0:
        data['outbound_url'] = url_for('relations_api.index', source=entity.id)
    
    return data
Example #2
0
def to_rest(entity):
    """ Full serialization of the entity. """
    data = to_rest_base(entity)
    data['created_at'] = entity.created_at
    data['updated_at'] = entity.updated_at

    ss = [schemata_logic.to_rest_index(s) for s in entity.schemata]
    data['schemata'] = ss

    data['properties'] = {}
    for prop in entity.active_properties:
        name, prop = properties_logic.to_rest(prop)
        data['properties'][name] = prop

    data['inbound_relations'] = entity.inbound.count()
    if data['inbound_relations'] > 0:
        data['inbound_url'] = url_for('relations_api.index', target=entity.id)

    data['outbound_relations'] = entity.outbound.count()
    if data['outbound_relations'] > 0:
        data['outbound_url'] = url_for('relations_api.index', source=entity.id)

    return data
Example #3
0
def to_rest(relation):
    data = to_rest_base(relation)
    for prop in relation.active_properties:
        name, prop = properties_logic.to_rest(prop)
        data['properties'][name] = prop
    return data
Example #4
0
def to_rest(relation):
    data = to_rest_base(relation)
    for prop in relation.active_properties:
        name, prop = properties_logic.to_rest(prop)
        data['properties'][name] = prop
    return data