ilabs package

Submodules

ilabs.adapters module

Adapter classes for message processing

  1. syntazo 1996- 2016

syntazo opensource

coded by: thanos vassilakis

$RCSfile: __init__.py,v $ $Date: 2004/07/16 17:36:28 $ $Revision: 1.3 $

class ilabs.adapters.Adapter(source=None)[source]

Bases: ilabs.core.Node

Abstarct adapter. The abtsract adapter is designed to take on input, L{source}.

agentClass

alias of DeliveryAgent

close()[source]

Use close to clean up.

pack(message)[source]

pack a message in an L{agentClass}, return the delivery agent Uses agentClass to create an agent instance and gives message to the delivery agent.

@param message: a message extracted by readMessage @return: a delivery agent, with message (usually !?!) @rtype: an agent, some subclass of DeliveryAgent

read(*args)[source]

Basic logic of an adapter. Read from source a message, L{pack} it and then send it. Continue until there are no more messages.

@param args: an argument list of what ever you whant to pass to readMessage

readMessage(*args)[source]

You should implement this method to extract a single message. @param args: You can use the args to help implement an early low level filtering. @return: a message

run(*args)

Basic logic of an adapter. Read from source a message, L{pack} it and then send it. Continue until there are no more messages.

@param args: an argument list of what ever you whant to pass to readMessage

source = None
class ilabs.adapters.File(source=None)[source]

Bases: ilabs.adapters.Adapter

File adapter. Will not send agent containing None messages.

destination = <open file '<stdout>', mode 'w'>
readMessage(*args)[source]

By default reads line by line of file.

send(agent)[source]

Sends the message not the agent. Will not send a None message.

source = <open file '<stdin>', mode 'r'>

ilabs.core module

Core classes for message processing

  1. integrationLabs 1996- 2016

coded by: thanos vassilakis

syntazo opensource

$RCSfile: core.py,v $ $Date: 2004/07/16 17:35:39 $ $Revision: 1.2 $

class ilabs.core.DeliveryAgent(wayslip=None, message=None)[source]

Bases: ilabs.core.ilabsObject

Implements a form of Visitor pattern. Its responsibility is to hold a message and deliver it to the correct processor method of the current node.

Use this class to encapsule a business message and control what method processes it at a node.

Was called Envelope - renamed to avoid confusion.

processNode(node)[source]

invokes Node.processAgent @param node: The node the message will be delivered to. @type node: Node object @return: a message instance.

wayslip = None
class ilabs.core.Node(name='')[source]

Bases: ilabs.core.ilabsObject

abstract node - don’t use - always subclass implentation of Node - with a single destination

connect(receiver, *args)[source]

Must be overridden. - override and always return self @param receiver: the node to receive the processed message @type receiver: Node subclass @param args: a list of args to facilitate the connection. @return: self

destination = None
disconnect(receiver=None, *args)[source]

disconnects a node to this pipe. @param reciever: the node to be connected. @type receiver: node to be disconnected. @param *args: list of args to facilitate disconnection.

@return: must return self @rtype: Node

name = ''
process(message)[source]

Override to process message

@param message: the sage to process @return: the message

processAgent(agent)[source]

Override is you need access to the delivery agent

@param agent: the delivery agent @type agent: DeliveryAgent @return: the delivery agent @rtype: DeliveryAgent

receive(agent)[source]

if you override invoke the agent’s process method and pass result with send

send(agent)[source]

Must be overridden. Should normally implement sending the agent onto the next node in the net work. override and always return self @param agent: the devilery agent @type agent: DeliveryAgent @return: self

class ilabs.core.Proxy(name='', node=None, whenEmpty=True)[source]

Bases: ilabs.core.Node

This is a node place holder or socket. You use this class when you want to be able to replace nodes without rewiring them. a Proxy pattern.

UNWIRED = True
WIREDTHRU = False
connect(receiver, *args)[source]

connects 1st as the pipelines destination and last node of chain to the actual destination @param reciever: the node to be connected. @type receiver: node

@return: must return self @rtype: Node

plugin(node)[source]

Plugs node into socket of Proxy. Will unplug and existing plugged-in node. @param reciever: the node to be connected. @type receiver: node @return: must return self @rtype: Node

send(agent)[source]

send the agent and sends it to 1st node

unplug()[source]

Un plugs current node from socket of Proxy. Disconects @param reciever: the node to be connected. @type receiver: node @return: must return self @rtype: Node

class ilabs.core.RouteTable[source]

Bases: ilabs.core.ilabsObject

Implements a default route table as a dictionary.

NoRoutes = []
addRoute(route, *criteria)[source]

inserts a route for each criterion.

@param route: Node to add to table keyed by criteria @type route: Node @param criteria: criteria by which router chooses the node to route Agent. @type criteria: list of any hashable parameters.

@return: self

allRoutes()[source]
cache = {}
removeRoute(route, *criteria)[source]
routes(*criteria)[source]

returns a list of routes given a set of criterion.

@param criteria: criteria by which router chooses the node to route Agent. @type criteria: list of any hashable parameters. @return: list of routes

tableClass

alias of dict

class ilabs.core.Router(name='', table=None, strategy=None)[source]

Bases: ilabs.core.Node

Abstarct message router

tableClass = route table class strategyClass = routing strategy

connect(route, *criteria)[source]
use to added a route with a given criteria

@param route: Node to add to table keyed by criteria @type route: Node @param criteria: criteria by which router chooses the node to route Agent. @type criteria: list of any hashable parameters.

@return: self

disconnect(*criteria)[source]
send(agent)[source]
setDefault(*routes)[source]
strategyClass

alias of RoutingStrategy

tableClass

alias of RouteTable

class ilabs.core.RoutingStrategy[source]

Bases: ilabs.core.ilabsObject

Abstarct routing strategy.

criteriaFromMessage(message, table)[source]

extracts routing citeria from an agents’s message.

getRoutesUsingAgent(agent, table)[source]
getRoutesUsingMessage(message, table)[source]
class ilabs.core.System(name='', configurator=None)[source]

Bases: ilabs.core.ilabsObject

run()[source]
setup(configurator)[source]
class ilabs.core.ilabsObject[source]

Bases: object

ilabs.patterns module

integration pattern classes for message processing

  1. integrationLabs 1996- 2004

coded by: thanos and friends

integrationLabs opensource

$RCSfile: __init__.py,v $ $Date: 2004/07/16 17:31:19 $ $Revision: 1.3 $

class ilabs.patterns.AllRoutes[source]

Bases: ilabs.core.RoutingStrategy

getRoutesUsingAgent(agent, table)[source]
class ilabs.patterns.Distributor(name='', table=None, strategy=None)[source]

Bases: ilabs.core.Router

strategyClass

alias of AllRoutes

tableClass

Will send messages to a list of connected subscribers

alias of RouteList

class ilabs.patterns.MessageProcessor(name='', router=None, concentrator=None)[source]

Bases: ilabs.core.Node

concentratorClass

alias of Node

connect(recipient)[source]
register(processor, *criteria)[source]
routerClass

alias of RecipientList

send(envelope)[source]
class ilabs.patterns.NodeBank(name='', *args)[source]

Bases: ilabs.patterns.NodeList

Behaves as a “parallel” bank of Nodes. Received messages are passed to the all the nodes in turn, the resulting messages are then sent on to the destination.

As with PipeLine this can be treated as a list. Use list operations (append, insert, del, setitem, etc) to set the nodes in the bank.

append(node)[source]
connect(receiver, *args)[source]
connectNode(node)[source]
onChange(*args)[source]

do nothing

receive(agent)[source]
class ilabs.patterns.NodeList(name='', *args)[source]

Bases: ilabs.core.Node

append(value)[source]
count(item)[source]
deferChange = False
extend(other)[source]
index(item, *args)[source]
insert(where, value)[source]
onChange = None
pop(i=-1)[source]
remove(item)[source]
reverse()[source]
sort(*args)[source]
class ilabs.patterns.PipeLine(name='', *args)[source]

Bases: ilabs.patterns.NodeList

Behaves as a chained list of Nodes. Received messages are passed to the first node, and the last node in turn sends the message to the destination.

The PipeLine’s process is called before and of the containing nodes. Use list operations (append, insert, del, setitem, etc) to set the nodes in the bank. When Nodes are added, inserted removed they are relinked to maintain the pipeline.

PipeLine = [Node1, Node2.. NodeN] NodeA -> PipeLine -> NodeB Expands to: NodeA -> PipeLine -> Node1 - > Node2 -> ...-> NodeN -> NodeB

connect(receiver, *args)[source]

connects 1st as the pipelines destination and last node of chain to the actual destination

used to relink the nodes

onChange(*args)[source]

called every time the list is altered to relink the nodes

send(agent)[source]

send the agent and sends it to 1st node

class ilabs.patterns.RecipientList(name='', table=None, strategy=None)[source]

Bases: ilabs.core.Router

Implements a router that sends a message to each route on the approriate subscription list

tableClass

alias of SubscriptionTable

class ilabs.patterns.RouteList[source]

Bases: ilabs.core.RouteTable

addRoute(route, *criteria)[source]
class ilabs.patterns.StateMachine(name, *args)[source]

Bases: ilabs.core.Node

Implements a hierachical state machine. Add attribute the states where states is a tuple of entries. Each entry can be one of: entry := current, message, next entry := current state, message, test, resultset

current := StateMachine.INIT
State collection of State StateMachine.ANY
message := Message
collection of Message StateMachine.ANY
next := State
StateMachine.CURRENT

test := python expression

resultset:= (result, next)+

some simple examples: states=((DrawerClosed, Eject, DrawerOpen),

(DrawerOpen, Eject, CDStopped), (CDStopped, Play, CDPlaying), (CDPlaying, Pause, CDPaused), ((CDPlaying,CDPaused), Stoped, CDStoped), (CDPaused, (Pause,Play) CDPlaying) )

states=((DrawerClosed, Eject, DrawerOpen), (DrawerOpen, Eject, “hasCd()”, (False, CDStopped), (True, DrawerClosed)), ((CDStopped, CDPlaying, CDPause), Eject, DrawerOpen), ((CDStopped, CDPause), Play, CDPlaying), (CDPlaying,CDPaused), Stoped, CDStoped), ((CDPlaying,CDPaused), NextTrack, “isLastTrack()”, (False, StateMachine.CURRENT), (True, CDStop)), ((CDPlaying,CDPaused), PrevTrack”, isFirstTrack()”, (False, StateMachine.CURRENT), (True, CDStop)) )

for more and hierachicle see the test code

ANY = ANY
CURRENT = CURRENT
DEFAULT = <object object>
INIT = INIT
LAST = LAST
class State(name='')[source]

Bases: ilabs.core.Node

process(node, message)[source]
StateMachine.UNDEF = INIT
StateMachine.buildTable()[source]
StateMachine.debug = False
StateMachine.getInitKey(message, currentState)
StateMachine.getKey(message, currentState)[source]
StateMachine.getNextState(message, *varspace)[source]
StateMachine.ofInterest()[source]
StateMachine.process(message, *varspace)[source]
class ilabs.patterns.SubscriptionTable[source]

Bases: ilabs.core.RouteTable

Implements a router table adds subscribing route (node) to an approriate distributer.

addRoute(node, *criteria)[source]

ilabs.utils module

Module contents

  1. syntazo 1996- 2016

coded by: thanos vassilakis and friends

syntazo integration package/framework

syntazo opensource

$RCSfile: __init__.py,v $ $Date: 2004/07/16 17:36:27 $ $Revision: 1.2 $