<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _retrieve(self, uid):
 """Return a dict with the contents of the paste, including the raw data, if any, as the key 'data'. Must pass in uid, not shortid."""

        query = dict(uid=uid)
        doc = self.db.pastes.find_one(query)
        if 'data_id' in doc:
            data_id = doc.pop('data_id')
            gfs = gridfs.GridFS(self.db)
            doc.update(data=gfs.get(data_id).read())
        return doc