Message Encoding

Supported Data Types

Communication between services is mediated through a layer of code which is written in C++. The only exception to this is when the LocalService class is used as a proxy to send a request to a serv- ice in the same process which is also implemented in Python. This means that except for when the Lo- calService class is being used, any data which is being transferred between services must go through a 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 basic Python scalar types, a list, a tuple or a dictionary. In addition to this, the Python None value may be used, as well as a number of extended types. The only limitation in respect of the Python compound types is that when using a dictionary, the keys must be of type string. Further, when a tuple appears within any data, the recipient will see it 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"})

The extended types 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 Boolean type should behave correctly with respect to all truth type tests. If the default arguments for the constructor of Date and DateTime types are 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())

When using the various date and time types, they should be 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

 

 

 

 

 

 

 

 

 

 

 

80

Page 80
Image 80
Python Python Manual, 7.0pl5 manual Supported Data Types, Yyyy-Mm-Dd