Simple Marshalling/demarshalling frameworkA pair of components for marshalling and demarshalling data respectively. You supply a class containing methods to marshall and demarshall the data in the way you want. The idea is that you would place this between your logic and a network socket to transform the data to and from a form suitable for transport. Example usageMarshalling and demarshalling a stream of integers: class SerialiseInt: def marshall(int): return str(int) marshall = staticmethod(marshall) def demarshall(string): return int(string) demarshall = staticmethod(demarshall) Pipeline( producer(...), Marshaller(SerialiseInt), sender(...) ).activate() Pipeline( receiver(...), DeMarshaller(SerialiseInt), consumer(...) ).activate() How does it work?When instantiating the Marshaller or DeMarshaller components, you provide an object (eg. class) containing these static methods:
Marshaller requires only the marshall(...) static method, and DeMarshaller requires only demarshall(...). Why static methods? Because marshalling/demarshalling is a stateless activity. This distinguishes marshalling activity from other protocols and other processes that can be implemented with a similar style of framework. For simplicity this component expects to be given an entire object to marshall or demarshall. This requires the user to deal with the framing and deframing of objects separately. Any data sent to the Marshaller or DeMarshaller components' "inbox" inbox is passed to the marshall(...) or demarshall(...) method respectively of the class you supplied. The result is immediately sent on out of the components' "outbox" outbox. If a producerFinished or shutdownMicroprocess message is received on the components' "control" inbox, it is sent on out of the "signal" outbox. The component will then immediately terminate. Post scriptThe initial data format this is designed to work with is the MimeDict object. It is expected that there will be a more complex marshaller that supports receiving that is capable of receiving objects segmented over multiple messages. Kamaelia.Util.Marshalling.DeMarshallerclass DeMarshaller(Axon.Component.component)DeMarshaller(klass) -> new DeMarshaller component. A component for demarshalling data (deserialising it from a string). Keyword arguments: - klass -- a class with static method: demarshall(data) that returns the data, demarshalled. Inboxes
Outboxes
Methods defined hereWarning! You should be using the inbox/outbox interface, not these methods (except construction). This documentation is designed as a roadmap as to their functionalilty for maintainers and new component developers. __init__(self, klass)x.__init__(...) initializes x; see x.__class__.__doc__ for signature main(self)Main loop. Kamaelia.Util.Marshalling.Marshallerclass Marshaller(Axon.Component.component)Marshaller(klass) -> new Marshaller component. A component for marshalling data (serialising it to a string). Keyword arguments:
Inboxes
Outboxes
Methods defined hereWarning! You should be using the inbox/outbox interface, not these methods (except construction). This documentation is designed as a roadmap as to their functionalilty for maintainers and new component developers. __init__(self, klass)x.__init__(...) initializes x; see x.__class__.__doc__ for signature main(self)Main loop. FeedbackGot a problem with the documentation? Something unclear that could be clearer? Want to help improve it? Constructive criticism is very welcome - especially if you can suggest a better rewording! Please leave you feedback here in reply to the documentation thread in the Kamaelia blog. -- Automatic documentation generator, 05 Jun 2009 at 03:01:38 UTC/GMT |
Kamaelia
is an open source project originated from and guided by BBC
Research. For more information browse the site or get in
contact.
This is an ongoing community based development site. As a result the contents of this page is the opinions of the contributors of the pages involved not the organisations involved. Specificially, this page may contain personal views which are not the views of the BBC. (the site is powered by a wiki engine)
(C) Copyright 2008 Kamaelia Contributors, including the British Broadcasting Corporation, All Rights Reserved.