def instance_new_entity(data):

    fields = ('id', 'created', 'modified',
              'entity_id', 'previous_id', 'status', 'available')
    if 'card' in data:
        kind = data['card'].get('kind')
        if kind in card_map:
            return card_map[kind](omit(data['card'], fields))
    elif 'unit' in data:
        return Unit(omit(data['unit'], fields))
    elif 'set' in data:
        return Set(omit(data['set'], fields))
Given a kind and some json, call insert on that kind
dataset/ETHPy150Open heiskr/sagefy/server/modules/entity.py/instance_new_entity