Module yami :: Class Parameters
[frames] | no frames]

Class Parameters

object --+
         |
        Parameters

Collection of message parameters.

A collection of message parameters is a list of typed {name, value} pairs. Each entry in this collection has a unique name and can have one of the following types:

The names of entries are searched for using case-sensitive comparisons.

Note: The instances of this class should not be used from multiple threads without synchronization; it is safe to use separate instances in separate threads.

Note: The entries are ordered - the order in which they are created influences the final serialized form of the message payload. Newly created entries are appended to the end of the collection unless there is an existing empty slot that can be reused - the appropriate slot is searched for from the beginning to the end of the collection and if no free slot is found the collection is extended at the end. The above guarantee concerns the user code that relies on predictable serialization.

Instance Methods
 
__init__(self)
Default constructor, creates an empty collection of parameters.
 
__setitem__(self, name, value)
Sets the given value in the named slot.
 
__getitem__(self, name)
Returns the value of the named slot.
 
__delitem__(self, name)
Removes the given entry from the collection.
 
__len__(self)
Gets the current size of the collection.
 
__in__(self, name)
Checks if the entry with the given name (key) exists.
 
__iter__(self)
Gets the iterator over the list of keys.
 
keys(self)
Gets the iterator over the list of keys.
 
values(self)
Gets the iterator over the list of values.
 
items(self)
Gets the iterator over the list of items.
 
serialize(self)
Serializes the content of the whole collection.
 
deserialize(self, buf)
Deserializes from the given buffer.
 
__str__(self)
Returns a string representation of the content.

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __subclasshook__

Properties

Inherited from object: __class__

Method Details

__init__(self)
(Constructor)

 

Default constructor, creates an empty collection of parameters.

Overrides: object.__init__

__setitem__(self, name, value)
(Index assignment operator)

 

Sets the given value in the named slot.

If the given slot is already used, its value is replaced.

__delitem__(self, name)
(Index deletion operator)

 

Removes the given entry from the collection.

Note: The removed entry leaves a hole (empty slot) in the collection that can be reused by newly added entries.

__iter__(self)

 

Gets the iterator over the list of keys.

The iterator visits only those entries which are used (in other words, it skips unused slots).

keys(self)

 

Gets the iterator over the list of keys.

The iterator visits only those entries which are used (in other words, it skips unused slots).

values(self)

 

Gets the iterator over the list of values.

The iterator visits only those entries which are used (in other words, it skips unused slots).

items(self)

 

Gets the iterator over the list of items.

The iterator visits only those entries which are used (in other words, it skips unused slots).

serialize(self)

 

Serializes the content of the whole collection.

Returns the binary string with the serialized content.

deserialize(self, buf)

 

Deserializes from the given buffer.

Note: The current content of this object is not cleared before attempting deserialization and each retrieved data element is merged into the current content as if done by inserting entries individually. In most cases deserialization will be performed to the empty Parameters object (to reconstruct it to the form that was used for serialization), but deserialization onto non-empty object might be occasionally useful as a way of merging two collections.

__str__(self)
(Informal representation operator)

 

Returns a string representation of the content.

This function is supposed to be used by unit tests and for simple debugging.

Overrides: object.__str__