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

Class Attachment

source code

An arbitrary file attachment.

Conceptually, an attachment is composed of these parts:

  1. A MIME type, as a string.
  2. A description, as a structured text string.
  3. A file name, corresponding to the original name of the file from which the attachment was uploaded, or the name of the file to use when the attachment is presented to the user in a file system.
  4. A block of arbitrary data.

For efficiency reasons, the attachment data is not stored in the attachment. Instead, a *location* is stored, which is a key into the associated 'AttachmentStore' object.

Instance Methods [hide private]
 
__init__(self, mime_type, description, file_name, location, store)
Create a new attachment.
source code
 
GetMimeType(self)
Return the attachment's MIME type.
source code
 
GetDescription(self)
Return the attachment's description.
source code
 
GetFileName(self)
Return the attachment's file name.
source code
 
GetLocation(self)
Return the attachment's location in an attachment store.
source code
 
GetData(self)
Get attachment data.
source code
 
GetDataFile(self)
Return the path to a file containing attachment data.
source code
 
GetStore(self)
Return the store in which this attachment is located.
source code
 
Move(self, store, location)
Move the 'Attachment' to a new location.
source code
 
__str__(self) source code
 
__cmp__(self, other) source code
Method Details [hide private]

__init__(self, mime_type, description, file_name, location, store)
(Constructor)

source code 

Create a new attachment.

'mime_type' -- The MIME type. If 'None' or an empty string, the function attempts to guess the MIME type from other information.

'description' -- A description of the attachment contents.

'file_name' -- The user-visible file name to associate the attachment.

'location' -- The location in an attachment store at which to find the attachment data.

'store' -- The attachment store in which the data is stored.

GetData(self)

source code 

Get attachment data.

returns -- The attachment data.

GetDataFile(self)

source code 

Return the path to a file containing attachment data.

returns -- A file system path. The file should be considered read-only, and should not be modified in any way.

GetStore(self)

source code 

Return the store in which this attachment is located.

returns -- The 'AttachmentStore' that contains this attachment.

Move(self, store, location)

source code 

Move the 'Attachment' to a new location.

'store' -- The 'AttachmentStore' that will contain the attachment.

'location' -- The location of the attachment within its current store.