Package pyamf :: Module amf3 :: Class Context

[hide private]
[frames] | no frames]

# Class Context

source code

I hold the AMF3 context for en/decoding streams.

Instance Methods | [hide private]

__init__(self, exceptions=True) x.__init__(...) initializes x; see x.__class__.__doc__ for signature | source code

clear(self) Clears the context. | source code

setObjectAlias(self, obj, alias) Maps an object to an aliased object. | source code

getObjectAlias(self, obj) Get an alias of an object. | source code

`str`

getString(self, ref) Gets a string based on a reference `ref`. | source code

`int`

getStringReference(self, s) Return string reference. | source code

`int`

addString(self, s) Creates a reference to `s`. | source code

getClassByReference(self, ref) Return class reference. | source code

getClass(self, klass) Return class reference. | source code

addClass(self, alias, klass) Creates a reference to `class_def`. | source code

getLegacyXML(self, ref) Return the legacy XML reference. | source code

`int`

getLegacyXMLReference(self, doc) Return legacy XML reference. | source code

`int`

addLegacyXML(self, doc) Creates a reference to `doc`. | source code

__copy__(self) | source code

Inherited from `BaseContext`: `addObject`, `getClassAlias`, `getObject`, `getObjectReference` Inherited from `object`: `__delattr__`, `__getattribute__`, `__hash__`, `__new__`, `__reduce__`, `__reduce_ex__`, `__repr__`, `__setattr__`, `__str__`

Instance Variables | [hide private]

`list` | classes A list of ClassDefinition.
`list` | legacy_xml A list of legacy encoded XML documents.
`list` | strings A list of string references.
Inherited from `BaseContext`: `class_aliases`, `exceptions`, `objects`

Properties | [hide private]

Inherited from `object`: `__class__`

Method Details | [hide private]

### __init__(self, exceptions=True)
(Constructor)

source code

x.__init__(...) initializes x; see x.__class__.__doc__ for signature

Overrides: object.__init__
  (inherited documentation)

### clear(self)

source code

Clears the context.

Overrides: BaseContext.clear

### setObjectAlias(self, obj, alias)

source code

Maps an object to an aliased object.

Since: 0.4

### getObjectAlias(self, obj)

source code

Get an alias of an object.

Raises:
  - `pyamf.ReferenceError` - Unknown object alias.
  - `pyamf.ReferenceError` - Unknown mapped alias.

Since: 0.4

### getString(self, ref)

source code

Gets a string based on a reference `ref`.

Parameters:
  - `ref` (`str`) - The reference index.
Returns: `str`
  The referenced string.
Raises:
  - `pyamf.ReferenceError` - The referenced string could not be found.

### getStringReference(self, s)

source code

Return string reference.

Parameters:
  - `s` (`str`) - The referenced string.
Returns: `int`
  The reference index to the string.
Raises:
  - `pyamf.ReferenceError` - The string reference could not be found.

### addString(self, s)

source code

Creates a reference to `s`. If the reference already exists, that reference is returned.

Parameters:
  - `s` (`str`) - The string to be referenced.
Returns: `int`
  The reference index.
Raises:
  - `TypeError` - The parameter `s` is not of `basestring` type.
  - `pyamf.ReferenceError` - Trying to store a reference to an empty string.

### getClassByReference(self, ref)

source code

Return class reference.

Returns:
  Class reference.
Raises:
  - `pyamf.ReferenceError` - The class reference could not be found.

### getClass(self, klass)

source code

Return class reference.

Returns:
  Class reference.
Raises:
  - `pyamf.ReferenceError` - The class reference could not be found.

### addClass(self, alias, klass)

source code

Creates a reference to `class_def`.

Parameters:
  - `alias` - `ClassDefinition` instance.

### getLegacyXML(self, ref)

source code

Return the legacy XML reference. This is the `flash.xml.XMLDocument` class in ActionScript 3.0 and the top-level `XML` class in ActionScript 1.0 and 2.0.

Parameters:
  - `ref` (`int`) - The reference index.
Returns:
  Instance of ET
Raises:
  - `pyamf.ReferenceError` - The legacy XML reference could not be found.

### getLegacyXMLReference(self, doc)

source code

Return legacy XML reference.

Parameters:
  - `doc` (ET) - The XML document to reference.
Returns: `int`
  The reference to `doc`.
Raises:
  - `pyamf.ReferenceError` - The reference could not be found.

### addLegacyXML(self, doc)

source code

Creates a reference to `doc`.

If `doc` is already referenced that index will be returned. Otherwise a new index will be created.

Parameters:
  - `doc` (ET) - The XML document to reference.
Returns: `int`
  The reference to `doc`.

### __copy__(self)

source code

Overrides: BaseContext.__copy__