コード例 #1
0
ファイル: model.py プロジェクト: curvetips/s4u.image
 def _delete(self):
     """Remove image scale from database and filesystem.
     """
     try:
         delete_file(self.filesystem_path)
     except OSError as e:
         if e.errno != errno.ENOENT:
             raise
     object_session(self).delete(self)
コード例 #2
0
ファイル: model.py プロジェクト: curvetips/s4u.image
 def delete(self):
     """Delete this image including all scales from the database and disk.
     """
     self._delete_scales()
     try:
         delete_file(self.filesystem_path)
     except OSError as e:
         if e.errno != errno.ENOENT:
             raise
     object_session(self).delete(self)
コード例 #3
0
ファイル: model.py プロジェクト: curvetips/s4u.image
 def _delete_scales(self):
     """Remove all existing image scales.
     """
     session = object_session(self)
     scales = session.query(ImageScale).filter(ImageScale.image_id == self.id)
     for scale in scales:
         try:
             delete_file(scale.filesystem_path)
         except OSError as e:
             if e.errno != errno.ENOENT:
                 raise
     scales.delete()
コード例 #4
0
ファイル: model.py プロジェクト: curvetips/s4u.image
    def replace(self, data, filename=None):
        """Replace the image contents.

        This method should be used to modify images. This method will
        delete old old image scales and switch to a new filename and
        URL.

        :param str data: Raw image data.
        :param str filename: Image filename (optional)

        """
        self._delete_scales()
        try:
            delete_file(self.filesystem_path)
        except OSError as e:
            if e.errno != errno.ENOENT:
                raise
        self._set_content(data, filename)
コード例 #5
0
ファイル: __init__.py プロジェクト: disko/kotti_filestore
    def delete(self, id):
        """ Delete the object with the given ID.

        :param id: ID of the file object
        :type id: unicode

        :result: Success
        :rtype: bool
        """

        # The kotti.events.ObjectDelete Event fires when the transaction is
        # already committing. It is safe to use os.unlink
        if transaction.get().status == "Committing":
            os.unlink(self.path(id))
            self.remove_base_directory(os.path.split(self.path(id=id))[0])
        else:
            # TODO: call remove_base_directory during transaction
            delete_file(self.path(id))
コード例 #6
0
    def delete(self, id):
        """ Delete the object with the given ID.

        :param id: ID of the file object
        :type id: unicode

        :result: Success
        :rtype: bool
        """

        # The kotti.events.ObjectDelete Event fires when the transaction is
        # already committing. It is safe to use os.unlink
        if transaction.get().status == "Committing":
            os.unlink(self.path(id))
            self.remove_base_directory(os.path.split(self.path(id=id))[0])
        else:
            # TODO: call remove_base_directory during transaction
            delete_file(self.path(id))