def minimize_attachment(attachment, doc_id):
    """
    Takes an attachment obtained from a document in an experiment object and 
    strips it down to a subset of desired fields. The document @id, given by
    doc_id, is prepended to the attachment href.
    """
    minimized_attachment = {}
    
    for key in ('md5sum', 'href'):
        if key in attachment:
            if key == 'href':
                minimized_attachment[key]=doc_id + attachment[key]
            elif key == 'md5sum':
                minimized_attachment[key] = attachment[key]
    
    return minimized_attachment