- for row in db_conn.exec('SELECT * FROM process_titles '
- 'WHERE parent = ?', (process.id_,)):
- process.title.history[row[1]] = row[2]
- for row in db_conn.exec('SELECT * FROM process_descriptions '
- 'WHERE parent = ?', (process.id_,)):
- process.description.history[row[1]] = row[2]
- for row in db_conn.exec('SELECT * FROM process_efforts '
- 'WHERE parent = ?', (process.id_,)):
- process.effort.history[row[1]] = row[2]
- for row in db_conn.exec('SELECT * FROM process_steps '
- 'WHERE owner = ?', (process.id_,)):
- process.explicit_steps += [ProcessStep.from_table_row(db_conn,
- row)]
- for row in db_conn.exec('SELECT condition FROM process_conditions '
- 'WHERE process = ?', (process.id_,)):
- process.conditions += [Condition.by_id(db_conn, row[0])]
- for row in db_conn.exec('SELECT condition FROM process_fulfills '
- 'WHERE process = ?', (process.id_,)):
- process.fulfills += [Condition.by_id(db_conn, row[0])]
- for row in db_conn.exec('SELECT condition FROM process_undoes '
- 'WHERE process = ?', (process.id_,)):
- process.undoes += [Condition.by_id(db_conn, row[0])]
+ if isinstance(process.id_, int):
+ for name in ('title', 'description', 'effort'):
+ table = f'process_{name}s'
+ for row in db_conn.all_where(table, 'parent', process.id_):
+ getattr(process, name).history_from_row(row)
+ for row in db_conn.all_where('process_steps', 'owner',
+ process.id_):
+ step = ProcessStep.from_table_row(db_conn, row)
+ process.explicit_steps += [step]
+ for name in ('conditions', 'fulfills', 'undoes'):
+ table = f'process_{name}'
+ for row in db_conn.all_where(table, 'process', process.id_):
+ target = getattr(process, name)
+ target += [Condition.by_id(db_conn, row[1])]