MessageEncoding
80
Supported Data Types
Communication between services is mediated through a layer of code which is written in C++. The
onlyexception to this iswhen the LocalServiceclass is used as a proxy to send a request to a serv-
icein the sameprocess whichis also implementedin Python. This meansthat except f or when the Lo-
calService class is being used, any data which is being transferred betwee n services must go
througha process of being encoded into a serialised form at the point of sending and then deserialised
at the point of reception.
Data which is being sent between services is not limited to that of just a string. The data to be sent can
consist of any of the basicPython scalar types, a list, a tuple or a dictionary. In addition to this, the
PythonNone value may be used, as well as a number of extended types. The only limitation in respect
ofthe Python compound types is that whe n usinga dictionary, thekeys must be of type string. Further,
when a tuple appears within any data, the recipient will seeit as a list and not a tuple. It is not possible
to send data which is cyclically self referential.
self.publishReport("string","value")
self.publishReport("list",[1,1L,1.1,None])
self.publishReport("dictionary",{"key":"value"})
Theextende dtypes which are supported are Boolean,Binary,Date,DateTime,Time and Du-
ration. For the Boolean type, there are also predefined values for True and False.The
Booleantype should behave correctly with respect to all truth type tests. If the default arguments for
theconstructor of Date andDateTime typesare used, they will be initialised to the current local date
and current local date and time respectively.
self.publishReport("true",netsvc.True)
self.publishReport("false,netsvc.False)
self.publishReport("boolean",netsvc.Boolean(1))
self.publishReport("binary",netsvc.Binary("value"))
# current local date
self.publishReport("date",netsvc.Date())
# current local date/time
self.publishReport("dateTime",netsvc.DateTime())
Whenusing the various date and time types ,they shouldbe initialised with string values corresponding
to what type they represent. The format and range of these values should be the subset of values pos-
sible under the ISO 8601 date/time standard as described by the XML Schema Datatypes 2001 speci-
fication, examples of which are illustrated below.
Type Format Sample
Date YYYY-MM-DD 2001-12-25