Package qm :: Module attachment :: Class AttachmentStore
[hide private]
[frames] | no frames]

Class AttachmentStore
source code

object --+
         |
        AttachmentStore
Known Subclasses:
FileAttachmentStore

Interface for classes which store attachment data.

An attachment store stores the raw data for an attachment. The store is not responsible for storing auxiliary information, including the attachment's description, file name, or MIME type.

Users of an 'AttachmentStore' reference attachment data by a *location*, which is stored with the attachment.

Please note that the 'AttachmentStore' interface provides methods for retrieving attachment data only; not for storing it. The interface for storing may be defined in any way by implementations.

Instance Methods [hide private]
  GetData(self, location)
Return the data for an attachment.
  GetDataFile(self, location)
Return the path to a file containing the data for 'attachment'.
  GetSize(self, location)
Return the size of the data for an attachment.
  HandleDownloadRequest(self, request)
Handle a web request to download attachment data.
  Store(self, attachment, location)
Add an attachment to the store.

Inherited from object: __delattr__, __getattribute__, __hash__, __init__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __str__


Class Variables [hide private]

Inherited from object: __class__


Method Details [hide private]

GetData(self, location)

source code 

Return the data for an attachment.

returns -- A string containing the attachment data.

GetDataFile(self, location)

source code 

Return the path to a file containing the data for 'attachment'.

returns -- A file system path.

The file is read-only, and may be a temporary file. The caller should not modify the file in any way.

GetSize(self, location)

source code 

Return the size of the data for an attachment.

returns -- The length of the attachment data, in bytes.

This method may be overridden by derived classes.

HandleDownloadRequest(self, request)

source code 

Handle a web request to download attachment data.

'request' -- A 'WebRequest' object. The location of the attachment data is stored in the 'location' property, and the MIME type in the 'mime_type' property.

returns -- A pair '(mime_type, data)' where 'mime_type' is the MIME type stored in the request and 'data' is the contents of the attachment.

Store(self, attachment, location)

source code 

Add an attachment to the store.

'attachment' -- The 'Attachment' to store.

'location' -- The location in which to store the 'attachment'.