Package legume :: Module messages :: Class MessageFactory
[frames] | no frames]

Class MessageFactory

object --+
         |
        MessageFactory

Instance Methods
 
__init__(self)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
 
add(self, *message_classes)
Add message class(es) to the message factory.
 
get_by_id(self, id)
Obtain a message class by specifying the packets MessageTypeID.
 
get_by_name(self, name)
Obtain a message class by specifying the packets name.
 
is_a(self, message_instance, message_name)
Determine if message_instance is an instance of the named message class.

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

Properties

Inherited from object: __class__

Method Details

__init__(self)
(Constructor)

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

Overrides: object.__init__
(inherited documentation)

add(self, *message_classes)

 

Add message class(es) to the message factory.
The parameters to this method must be subclasses of BaseMessage.

A MessageError will be raised if a message already exists in
this factory with an identical name or MessageTypeID.

get_by_id(self, id)

 

Obtain a message class by specifying the packets MessageTypeID.
If the message cannot be found a MessageError exception is raised.

get_by_name(self, name)

 

Obtain a message class by specifying the packets name.
If the message cannot be found a MessageError exception is raised.

is_a(self, message_instance, message_name)

 

Determine if message_instance is an instance of the named message class.

Example:
>>> tp = TestPacket1()
>>> message_factory.is_a(tp, 'TestPacket1')
True