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, *args, **kwargs)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
source code
 
writeElement(self, data, use_references=True, use_proxies=None)
Writes the data.
source code
 
writeClass(self, *args, **kwargs)
Classes cannot be serialised.
source code
 
writeUndefined(self, *args, **kwargs)
Writes an pyamf.Undefined value to the stream.
source code
 
writeNull(self, *args, **kwargs)
Writes a null value to the stream.
source code
 
writeBoolean(self, n, **kwargs)
Writes a Boolean to the stream.
source code
 
_writeInteger(self, n)
AMF3 integers are encoded.
source code
 
writeInteger(self, n, **kwargs)
Writes an integer to the stream.
source code
 
writeNumber(self, n, **kwargs)
Writes a float to the stream.
source code
 
_writeString(self, n, **kwargs)
Writes a raw string to the stream.
source code
 
writeString(self, n, writeType=True, **kwargs)
Writes a string to the stream.
source code
 
writeDate(self, n, use_references=True, **kwargs)
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
 
writeInstance(self, obj, **kwargs)
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, **kwargs)
Writes a ByteArray to the data stream.
source code
 
writeXML(self, n, use_references=True, use_proxies=None)
Writes a XML string to the data stream.
source code

Inherited from BaseEncoder: writeFunc

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, timezone_offset

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, *args, **kwargs)
(Constructor)

source code 

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

Overrides: object.__init__
(inherited documentation)

writeElement(self, data, use_references=True, use_proxies=None)

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

_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, **kwargs)

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, **kwargs)

source code 

Writes a float to the stream.

Parameters:
  • n (float)

_writeString(self, n, **kwargs)

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.

writeString(self, n, writeType=True, **kwargs)

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.

writeDate(self, n, use_references=True, **kwargs)

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.

writeInstance(self, obj, **kwargs)

source code 

Read class definition.

Parameters:
  • obj - The class instance to be encoded.

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, **kwargs)

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, use_proxies=None)

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'),
...