def init():
    r'''Reads the types in from database.

    This ensures that references to the same type will have the same type id
    as prior runs of the compiler.
    '''
    for row in crud.read_as_dicts('type'):
        getattr(globals(), row['kind']).from_db(row)
def read_triples(block_id):
    r'''Reads and returns list of all `triple` objects in block_id.
    '''
    #print >> sys.stderr, "read_triples", block_id
    triple_id_map = {}
    triples = [triple(row, triple_id_map)
               for row in crud.read_as_dicts('triples', block_id=block_id)]
    #print >> sys.stderr, "read_triples: triples", triples
    for t in triples:
        t.connect_children(triple_id_map)
    for t in triples:
        t.get_children()
    return triples