def attach(data, session):
    """
    Add all data objects to a database session.

    """
    instances = []
    for name in dir(data):
        if name.startswith('_'):
            continue

        instance = getattr(data, name)
        session.add(instance)
        instances.append(instance)

    return data