Package mms :: Module message :: Class DataPart
[hide private]
[frames] | no frames]

Class DataPart

source code

This class represents a data entry in the MMS body.

A DataPart objectencapsulates any data content that is to be added to the MMS (e.g. an image file, raw image data, audio clips, text, etc).

A DataPart object can be queried using the Python built-in len() function.

This encapsulation allows custom header/parameter information to be set for each data entry in the MMS. Refer to [5] for more information on these.

Instance Methods [hide private]
 
__init__(self, srcFilename=None) source code
 
_getContentType(self)
Returns the string representation of this data part's "Content-Type" header.
source code
 
_setContentType(self, value)
Convenience method that sets the content type string, with no parameters
source code
 
fromFile(self, filename)
Load the data contained in the specified file
source code
 
setData(self, data, contentType, ctParameters={})
Explicitly set the data contained by this part
source code
 
setText(self, text)
Convenience wrapper method for setData()
source code
 
__len__(self)
Provides the length of the data encapsulated by this object
source code
Properties [hide private]
  contentType
Returns the string representation of this data part's "Content-Type" header.
  data
A buffer containing the binary data of this part
Method Details [hide private]

__init__(self, srcFilename=None)
(Constructor)

source code 
Parameters:
  • srcFilename (str) - If specified, load the content of the file with this name

_getContentType(self)

source code 

Returns the string representation of this data part's "Content-Type" header. No parameter information is returned; to get that, access the "Content-Type" header directly (which has a tuple value)from this part's headers attribute.

This is equivalent to calling DataPart.headers['Content-Type'][0]

fromFile(self, filename)

source code 
Load the data contained in the specified file
Parameters:
  • filename (str) - The name of the file to open
Raises:
  • OSError - The filename is invalid

Note: This function clears any previously-set header entries.

setData(self, data, contentType, ctParameters={})

source code 
Explicitly set the data contained by this part
Parameters:
  • data (str) - The data to hold
  • contentType (str) - The MIME content type of the specified data
  • ctParameters (dict) - A dictionary containing any content type header parmaters to add, in the format: {<parameter_name> : <parameter_value>}

Note: This function clears any previously-set header entries.

setText(self, text)

source code 

Convenience wrapper method for setData()

This method sets the DataPart object to hold the specified text string, with MIME content type "text/plain".
Parameters:
  • text (str) - The text to hold

Property Details [hide private]

contentType

Returns the string representation of this data part's "Content-Type" header. No parameter information is returned; to get that, access the "Content-Type" header directly (which has a tuple value)from this part's headers attribute.

This is equivalent to calling DataPart.headers['Content-Type'][0]
Get Method:
mms.message.DataPart._getContentType(self) - Returns the string representation of this data part's "Content-Type" header.
Set Method:
mms.message.DataPart._setContentType(self, value) - Convenience method that sets the content type string, with no parameters

data

A buffer containing the binary data of this part
Get Method:
unreachable.data(self) - A buffer containing the binary data of this part