Package pyamf :: Module amf3 :: Class Encoder
[hide private]
[frames] | no frames]

Class Encoder

source code


Encodes an AMF3 data stream.

Nested Classes [hide private]
type or types.ClassType context_class
Holds the class that will create context objects for the implementing Encoder.
Instance Methods [hide private]
 
__init__(self, data=None, context=None, strict=False, use_proxies=None)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
source code
 
writeElement(self, data, use_references=True)
Writes the data.
source code
 
writeType(self, type)
Writes the data type to the stream.
source code
 
writeFunc(self, *args, **kwargs)
Functions cannot be serialised.
source code
 
writeUndefined(self, d, use_references=True)
Writes an pyamf.Undefined value to the stream.
source code
 
writeNull(self, n, use_references=True)
Writes a null value to the stream.
source code
 
writeBoolean(self, n, use_references=True)
Writes a Boolean to the stream.
source code
 
_writeInteger(self, n)
AMF3 integers are encoded.
source code
 
writeInteger(self, n, use_references=True)
Writes an integer to the stream.
source code
 
writeNumber(self, n, use_references=True)
Writes a non integer to the stream.
source code
 
_writeString(self, n, use_references=True)
Writes a raw string to the stream.
source code
 
writeString(self, n, use_references=True)
Writes a string to the stream.
source code
 
writeDate(self, n, use_references=True)
Writes a datetime instance to the stream.
source code
 
writeList(self, n, use_references=True, _use_proxies=None)
Writes a tuple, set or list to the stream.
source code
 
writeDict(self, n, use_references=True, _use_proxies=None)
Writes a dict to the stream.
source code
 
_getClassDefinition(self, obj)
Builds a class definition based on the obj.
source code
 
writeInstance(self, obj, use_references=True)
Read class definition.
source code
 
writeObject(self, obj, use_references=True, _use_proxies=None)
Writes an object to the stream.
source code
 
writeByteArray(self, n, use_references=True)
Writes a ByteArray to the data stream.
source code
 
writeXML(self, n, use_references=True)
Writes a XML string to the data stream.
source code

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __str__

Class Variables [hide private]
list type_map = [((<type 'builtin_function_or_method'>, <type 'buil...
A list of types -> functions.
Instance Variables [hide private]

Inherited from BaseEncoder: context, stream, strict

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, data=None, context=None, strict=False, use_proxies=None)
(Constructor)

source code 

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

Parameters:
  • data - Data stream.
  • context - Context.
Raises:
  • TypeError - The context parameter must be of type Context.
Overrides: object.__init__
(inherited documentation)

writeElement(self, data, use_references=True)

source code 

Writes the data.

Parameters:
  • data (mixed) - The data to be encoded to the AMF3 data stream.
  • use_references (bool) - Default is True.
Raises:
Overrides: BaseEncoder.writeElement

writeType(self, type)

source code 

Writes the data type to the stream.

Parameters:
  • type - ActionScript type.
Raises:

See Also: ACTIONSCRIPT_TYPES

writeFunc(self, *args, **kwargs)

source code 

Functions cannot be serialised.

Raises:
Overrides: BaseEncoder.writeFunc

writeUndefined(self, d, use_references=True)

source code 

Writes an pyamf.Undefined value to the stream.

Parameters:
  • d - The undefined data to be encoded to the AMF3 data stream.
  • use_references (bool) - Default is True.

writeNull(self, n, use_references=True)

source code 

Writes a null value to the stream.

Parameters:
  • n (null data.) - The null data to be encoded to the AMF3 data stream.
  • use_references (bool) - Default is True.

writeBoolean(self, n, use_references=True)

source code 

Writes a Boolean to the stream.

Parameters:
  • n (bool) - The boolean data to be encoded to the AMF3 data stream.
  • use_references (bool) - Default is True.

_writeInteger(self, n)

source code 

AMF3 integers are encoded.

Parameters:
  • n (integer data) - The integer data to be encoded to the AMF3 data stream.

See Also: Parsing Integers on OSFlash for more info.

writeInteger(self, n, use_references=True)

source code 

Writes an integer to the stream.

Parameters:
  • n (integer data) - The integer data to be encoded to the AMF3 data stream.
  • use_references (bool) - Default is True.

writeNumber(self, n, use_references=True)

source code 

Writes a non integer to the stream.

Parameters:
  • n (number data) - The number data to be encoded to the AMF3 data stream.
  • use_references (bool) - Default is True

_writeString(self, n, use_references=True)

source code 

Writes a raw string to the stream.

Parameters:
  • n (str or unicode) - The string data to be encoded to the AMF3 data stream.
  • use_references (bool) - Default is True.

writeString(self, n, use_references=True)

source code 

Writes a string to the stream. If n is not a unicode string, an attempt will be made to convert it.

Parameters:
  • n (basestring) - The string data to be encoded to the AMF3 data stream.
  • use_references (bool) - Default is True.

writeDate(self, n, use_references=True)

source code 

Writes a datetime instance to the stream.

Parameters:
  • n (datetime) - The Date data to be encoded to the AMF3 data stream.
  • use_references (bool) - Default is True.

writeList(self, n, use_references=True, _use_proxies=None)

source code 

Writes a tuple, set or list to the stream.

Parameters:
  • n (One of __builtin__.tuple, __builtin__.set or __builtin__.list) - The list data to be encoded to the AMF3 data stream.
  • use_references (bool) - Default is True.

writeDict(self, n, use_references=True, _use_proxies=None)

source code 

Writes a dict to the stream.

Parameters:
  • n (__builtin__.dict) - The dict data to be encoded to the AMF3 data stream.
  • use_references (bool) - Default is True.
Raises:
  • ValueError - Non int/str key value found in the dict
  • EncodeError - dict contains empty string keys.

_getClassDefinition(self, obj)

source code 

Builds a class definition based on the obj.

Raises:

writeInstance(self, obj, use_references=True)

source code 

Read class definition.

Parameters:
  • obj (instance data) - The class instance data to be encoded to the AMF3 data stream.
  • use_references (bool) - Default is True.

writeObject(self, obj, use_references=True, _use_proxies=None)

source code 

Writes an object to the stream.

Parameters:
  • obj (object data) - The object data to be encoded to the AMF3 data stream.
  • use_references (bool) - Default is True.
Raises:
  • EncodeError - Encoding an object in amf3 tagged as amf0 only.

writeByteArray(self, n, use_references=True)

source code 

Writes a ByteArray to the data stream.

Parameters:
  • n (ByteArray) - The ByteArray data to be encoded to the AMF3 data stream.
  • use_references (bool) - Default is True.

writeXML(self, n, use_references=True)

source code 

Writes a XML string to the data stream.

Parameters:
  • n (ET) - The XML Document to be encoded to the AMF3 data stream.
  • use_references (bool) - Default is True.

Class Variable Details [hide private]

type_map

A list of types -> functions. The types is a list of possible instances or functions to call (that return a bool) to determine the correct function to call to encode the data.
Type:
list
Value:
[((<type 'builtin_function_or_method'>,
   <type 'builtin_function_or_method'>,
   <type 'function'>,
   <type 'generator'>,
   <type 'module'>,
   <type 'function'>,
   <type 'instancemethod'>),
  'writeFunc'),
...