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.
  GetMimeType(self)
Return the attachment's MIME type.
  GetDescription(self)
Return the attachment's description.
  GetFileName(self)
Return the attachment's file name.
  GetLocation(self)
Return the attachment's location in an attachment store.
  GetData(self)
Get attachment data.
  GetDataFile(self)
Return the path to a file containing attachment data.
  GetStore(self)
Return the store in which this attachment is located.
  Move(self, store, location)
Move the 'Attachment' to a new location.
  __str__(self)
  __cmp__(self, other)

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.

GetMimeType(self)

source code 
Return the attachment's MIME type.

GetDescription(self)

source code 
Return the attachment's description.

GetFileName(self)

source code 
Return the attachment's file name.

GetLocation(self)

source code 
Return the attachment's location in an attachment store.

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.

__str__(self)
(Informal representation operator)

source code 

__cmp__(self, other)
(Comparison operator)

source code