Added `from_attachment()` method

Use Attachment objects instead of manually querying the database. (We
still need the initial manual query as there's no way to get all
attachments.)