3. Flex

The modules described in this chapter provide Flex support.

3.1. pyamf.flex — Flex

Compatibility classes/functions for Flex.

note:Not available in ActionScript 1.0 and 2.0.
see:Flex on Wikipedia (external)
since:0.1.0
class pyamf.flex.ArrayCollection(source=None)

I represent the ActionScript 3 based class flex.messaging.io.ArrayCollection used in the Flex framework.

The ArrayCollection class is a wrapper class that exposes an Array as a collection that can be accessed and manipulated using the methods and properties of the ICollectionView or IList interfaces in the Flex framework.

See:ArrayCollection on Livedocs (external)
Note:This class does not implement the RemoteObject part of the documentation.
Variable length:
 [read-only] The number of items in this collection. Introduced in 0.4.
addItem(item)

Adds the specified item to the end of the list.

Parameter:item (mixed) – The object to add to the collection.
Since:0.4
addItemAt(item, index)

Adds the item at the specified index.

Parameters:
  • item (mixed) – The object to add to the collection.
  • index – The index at which to place the item.
Raises IndexError:
 

If index is less than 0 or greater than the length of the list.

Since:

0.4

getItemAt(index, prefetch=0)

Gets the item at the specified index.

Parameters:
  • index (int) – The index in the list from which to retrieve the item.
  • prefetch – This param is ignored and is only here as part of the interface.
Raises IndexError:
 

if index < 0 or index >= length

Returns:

The item at index index.

Return type:

mixed.

Since:

0.4

getItemIndex(item)

Returns the index of the item if it is in the list such that getItemAt(index) == item.

Parameter:item (mixed.) – The item to find.
Returns:The index of the item or -1 if the item is not in the list.
Return type:int
Since:0.4
removeAll()

Removes all items from the list.

Since:0.4
removeItemAt(index)

Removes the item at the specified index and returns it. Any items that were after this index are now one index earlier.

Parameter:index – The index from which to remove the item.
Returns:The item that was removed.
Return type:mixed
Raises IndexError:
 If index is less than 0 or greater than length.
Since:0.4
setItemAt(item, index)

Places the item at the specified index. If an item was already at that index the new item will replace it and it will be returned.

Parameters:
  • item (mixed) – The new item to be placed at the specified index.
  • index (int) – The index at which to place the item.
Returns:

The item that was replaced, or None.

Return type:

mixed or None.

Raises IndexError:
 

If index is less than 0 or greater than length.

Since:

0.4

toArray()

Returns an Array that is populated in the same order as the IList implementation.

Returns:The array.
Return type:list
class pyamf.flex.ObjectProxy(object=None)

I represent the ActionScript 3 based class flex.messaging.io.ObjectProxy used in the Flex framework. Flex’s ObjectProxy class allows an anonymous, dynamic ActionScript Object to be bindable and report change events.

See:ObjectProxy on Livedocs (external)

3.2. pyamf.flex.messaging — Flex Messaging

Flex Messaging implementation.

This module contains the message classes used with Flex Data Services.

@see: U{RemoteObject on OSFlash (external) <http://osflash.org/documentation/amf3#remoteobject>}

@since: 0.1

class pyamf.flex.messaging.RemotingMessage(*args, **kwargs)

I am used to send RPC requests to a remote endpoint.

@see: U{RemotingMessage on Livedocs (external) <http://livedocs.adobe.com/flex/201/langref/mx/messaging/messages/RemotingMessage.html>}

class pyamf.flex.messaging.CommandMessage(*args, **kwargs)

Provides a mechanism for sending commands related to publish/subscribe messaging, ping, and cluster operations.

@see: U{CommandMessage on Livedocs (external) <http://livedocs.adobe.com/flex/201/langref/mx/messaging/messages/CommandMessage.html>}

@ivar operation: The command @type operation: C{int} @ivar messageRefType: hmm, not sure about this one. @type messageRefType: C{str}

AUTHENTICATION_MESSAGE_REF_TYPE
The server message type for authentication commands.
CLUSTER_REQUEST_OPERATION
This is used to request a list of failover endpoint URIs for the remote destination based on cluster membership.
DISCONNECT_OPERATION
This operation is used to indicate that a channel has disconnected.
LOGIN_OPERATION
This is used to send credentials to the endpoint so that the user can be logged in over the current channel. The credentials need to be C{Base64} encoded and stored in the body of the message.
LOGOUT_OPERATION
This is used to log the user out of the current channel, and will invalidate the server session if the channel is HTTP based.
PING_OPERATION
This is used to test connectivity over the current channel to the remote endpoint.
POLL_OPERATION
This is used to poll a remote destination for pending, undelivered messages.
SELECTOR_HEADER
Subscribe commands issued by a consumer pass the consumer’s C{selector} expression in this header.
SESSION_INVALIDATE_OPERATION
This is used to indicate that the client’s session with a remote destination has timed out.
SUBSCRIBE_OPERATION
This is used to subscribe to a remote destination.
SYNC_OPERATION
This is used by a remote destination to sync missed or cached messages back to a client as a result of a client issued poll command.
UNKNOWN_OPERATION
This is the default operation for new L{CommandMessage} instances.
UNSUBSCRIBE_OPERATION
This is used to unsubscribe from a remote destination.
getSmallMessage()

Return a ISmallMessage representation of this command message.

@since: 0.5

class pyamf.flex.messaging.AcknowledgeMessage(*args, **kwargs)

I acknowledge the receipt of a message that was sent previously.

Every message sent within the messaging system must receive an acknowledgement.

@see: U{AcknowledgeMessage on Livedocs (external) <http://livedocs.adobe.com/flex/201/langref/mx/messaging/messages/AcknowledgeMessage.html>}

ERROR_HINT_HEADER
Used to indicate that the acknowledgement is for a message that generated an error.
getSmallMessage()

Return a ISmallMessage representation of this acknowledge message.

@since: 0.5

class pyamf.flex.messaging.ErrorMessage(*args, **kwargs)

I am the Flex error message to be returned to the client.

This class is used to report errors within the messaging system.

@see: U{ErrorMessage on Livedocs (external) <http://livedocs.adobe.com/flex/201/langref/mx/messaging/messages/ErrorMessage.html>}

MESSAGE_DELIVERY_IN_DOUBT
If a message may not have been delivered, the faultCode will contain this constant.
RETRYABLE_HINT_HEADER

Header name for the retryable hint header.

This is used to indicate that the operation that generated the error may be retryable rather than fatal.

getSmallMessage()

Return a ISmallMessage representation of this error message.

@since: 0.5

class pyamf.flex.messaging.AbstractMessage(*args, **kwargs)

Abstract base class for all Flex messages.

Messages have two customizable sections; headers and data. The headers property provides access to specialized meta information for a specific message instance. The data property contains the instance specific data that needs to be delivered and processed by the decoder.

@see: U{AbstractMessage on Livedocs (external) <http://livedocs.adobe.com/flex/201/langref/mx/messaging/messages/AbstractMessage.html>}

@ivar body: Specific data that needs to be delivered to the remote
destination.

@type body: C{mixed} @ivar clientId: Indicates which client sent the message. @type clientId: C{str} @ivar destination: Message destination. @type destination: C{str} @ivar headers: Message headers. Core header names start with DS. @type headers: C{dict} @ivar messageId: Unique Message ID. @type messageId: C{str} @ivar timeToLive: How long the message should be considered valid and

deliverable.

@type timeToLive: C{int} @ivar timestamp: Timestamp when the message was generated. @type timestamp: C{int}

DESTINATION_CLIENT_ID_HEADER
Each message pushed from the server will contain this header identifying the client that will receive the message.
ENDPOINT_HEADER
Messages are tagged with the endpoint id for the channel they are sent over.
REMOTE_CREDENTIALS_HEADER
Messages that need to set remote credentials for a destination carry the C{Base64} encoded credentials in this header.
REQUEST_TIMEOUT_HEADER
The request timeout value is set on outbound messages by services or channels and the value controls how long the responder will wait for an acknowledgement, result or fault response for the message before timing out the request.
decodeSmallAttribute(attr, input)
@since: 0.5
encodeSmallAttribute(attr)
@since: 0.5
getSmallMessage()

Return a ISmallMessage representation of this object. If one is not available, L{NotImplementedError} will be raised.

@since: 0.5

class pyamf.flex.messaging.AsyncMessage(*args, **kwargs)

I am the base class for all asynchronous Flex messages.

@see: U{AsyncMessage on Livedocs (external) <http://livedocs.adobe.com/flex/201/langref/mx/messaging/messages/AsyncMessage.html>}

@ivar correlationId: Correlation id of the message. @type correlationId: C{str}

SUBTOPIC_HEADER
Messages that were sent with a defined subtopic property indicate their target subtopic in this header.
getSmallMessage()

Return a ISmallMessage representation of this async message.

@since: 0.5

3.3. pyamf.flex.data — Flex Data

Flex Data Management Service implementation.

This module contains the message classes used with Flex Data Management Service.

@since: 0.1.0

class pyamf.flex.data.DataMessage

I am used to transport an operation that occured on a managed object or collection.

This class of message is transmitted between clients subscribed to a remote destination as well as between server nodes within a cluster. The payload of this message describes all of the relevant details of the operation. This information is used to replicate updates and detect conflicts.

@see: U{DataMessage on Livedocs (external) <http://livedocs.adobe.com/flex/201/langref/mx/data/messages/DataMessage.html>}

class pyamf.flex.data.SequencedMessage

Response to L{DataMessage} requests.

@see: U{SequencedMessage on Livedocs (external) <http://livedocs.adobe.com/flex/201/langref/mx/data/messages/SequencedMessage.html>}

class pyamf.flex.data.PagedMessage

This messsage provides information about a partial sequence result.

@see: U{PagedMessage on Livedocs (external) <http://livedocs.adobe.com/flex/201/langref/mx/data/messages/PagedMessage.html>}

class pyamf.flex.data.DataErrorMessage

Special cases of ErrorMessage will be sent when a data conflict occurs.

This message provides the conflict information in addition to the L{ErrorMessage<pyamf.flex.messaging.ErrorMessage>} information.

@see: U{DataErrorMessage on Livedocs (external) <http://livedocs.adobe.com/flex/201/langref/mx/data/messages/DataErrorMessage.html>}