Submit
Path:
~
/
/
usr
/
lib
/
python2.7
/
site-packages
/
boto
/
sqs
/
File Content:
message.pyo
� ��Wc @ s� d Z d d l Z d d l Z d d l m Z d d l m Z d d l m Z d d l m Z d d l m Z d e f d � � YZ d e f d � � YZ d e f d � � YZ d e f d � � YZ d S( sX SQS Message A Message represents the data stored in an SQS queue. The rules for what is allowed within an SQS Message are here: http://docs.amazonwebservices.com/AWSSimpleQueueService/2008-01-01/SQSDeveloperGuide/Query_QuerySendMessage.html So, at it's simplest level a Message just needs to allow a developer to store bytes in it and get the bytes back out. However, to allow messages to have richer semantics, the Message class must support the following interfaces: The constructor for the Message class must accept a keyword parameter "queue" which is an instance of a boto Queue object and represents the queue that the message will be stored in. The default value for this parameter is None. The constructor for the Message class must accept a keyword parameter "body" which represents the content or body of the message. The format of this parameter will depend on the behavior of the particular Message subclass. For example, if the Message subclass provides dictionary-like behavior to the user the body passed to the constructor should be a dict-like object that can be used to populate the initial state of the message. The Message class must provide an encode method that accepts a value of the same type as the body parameter of the constructor and returns a string of characters that are able to be stored in an SQS message body (see rules above). The Message class must provide a decode method that accepts a string of characters that can be stored (and probably were stored!) in an SQS message and return an object of a type that is consistent with the "body" parameter accepted on the class constructor. The Message class must provide a __len__ method that will return the size of the encoded message that would be stored in SQS based on the current state of the Message object. The Message class must provide a get_body method that will return the body of the message in the same format accepted in the constructor of the class. The Message class must provide a set_body method that accepts a message body in the same format accepted by the constructor of the class. This method should alter to the internal state of the Message object to reflect the state represented in the message body parameter. The Message class must provide a get_body_encoded method that returns the current body of the message in the format in which it would be stored in SQS. i����N( t StringIO( t six( t Attributes( t MessageAttributes( t SQSDecodeErrort RawMessagec B s� e Z d Z d d d � Z d � Z d � Z d � Z d � Z d � Z d � Z d � Z d � Z d � Z d � Z d � Z RS( s Base class for SQS messages. RawMessage does not encode the message in any way. Whatever you store in the body of the message is what will be written to SQS and whatever is returned from SQS is stored directly into the body of the message. t c C s\ | | _ | j | � d | _ d | _ d | _ t | � | _ t | � | _ d | _ d S( N( t queuet set_bodyt Nonet idt receipt_handlet md5R t attributesR t message_attributest md5_message_attributes( t selfR t body( ( s4 /usr/lib/python2.7/site-packages/boto/sqs/message.pyt __init__T s c C s t | j | j � � S( N( t lent encodet _body( R ( ( s4 /usr/lib/python2.7/site-packages/boto/sqs/message.pyt __len__^ s c C s* | d k r | j S| d k r&