(self, name, stream=False)
Get named attachment

        :param stream: When true, return a file-like object that can be
        read at least once (streamers should not expect to seek within
        or read the contents of the returned file more than once).
Get named attachment
Get named attachment
def fetch_attachment(self, name, stream=False):
        """Get named attachment

        :param stream: When true, return a file-like object that can be
        read at least once (streamers should not expect to seek within
        or read the contents of the returned file more than once).
        """
        db = get_blob_db()
        try:
            try:
                key = self.external_blobs[name].key
            except KeyError:
                if self._migrating_blobs_from_couch:
                    return super(BlobMixin, self) \
                        .fetch_attachment(name, stream=stream)
                raise NotFound(name)
            meta = db.metadb.get(parent_id=self._id, key=key)
            blob = meta.open()
        except (NotFound, db.metadb.DoesNotExist):
            raise ResourceNotFound(
                "{model} {model_id} attachment: {name!r}".format(
                    model=type(self).__name__,
                    model_id=self._id,
                    name=name,
                ))
        if stream:
            return blob

        with blob:
            return blob.read()
def fetch_attachment ( self , name , stream = False ) : db = get_blob_db ( ) try : try : key = self . external_blobs [ name ] . key except KeyError : if self . _migrating_blobs_from_couch : return super ( BlobMixin , self ) . fetch_attachment ( name , stream = stream ) raise NotFound ( name ) meta = db . metadb . get ( parent_id = self . _id , key = key ) blob = meta . open ( ) except ( NotFound , db . metadb . DoesNotExist ) : raise ResourceNotFound ( "{model} {model_id} attachment: {name!r}" . format ( model = type ( self ) . __name__ , model_id = self . _id , name = name , ) ) if stream : return blob with blob : return blob . read ( )