Mapping of Scalar Types

Type

Format

Sample

 

 

 

DateTime

YYYY-MM-DDThh:mm:ss

2001-12-25T23:59:59

 

 

 

Time

hh:mm:ss

23:59:59

 

 

 

Duration

PnDTnHnMnS

P1DT23H59M59S

 

 

 

For the date and time types, the current Python implementation does not do any checking to determine if the supplied values are valid, but will pass them as is. Note that the XML Schema Datatypes speci- fication does allow for a timezone in a date and time, but it is recommended that all date and time val- ues be sent as UTC. In the C++ library, only classes corresponding to Date and DateTime exist.

These are OTC_Date and OTC_Time. The OTC_Time class is not able to handle timezones.

The only difference between the Binary type and using a string is that the value supplied via the Bi- nary type, will be encoded internally using "base64" encoding when being passed around. This has relevance because in XML most control characters are not permitted in string values. An XML imple- mentation can also collapse a "\r\n" combination to just "\n". If such characters may appear in a string, you should use the Binary type to ensure that they are preserved as is. Note that you do not however have to encode the string using base64 encoding first as the internal implementation will do this for you automatically.

Mapping of Scalar Types

When data is being serialised, the names attributed to scalar types derive from the XML Schema Da- tatypes 2001 specification. The only exception to this is the None type, which notionally is passed around internally with an empty type value. The mapping from Python types to those described in the XML Schema Datatypes specification is as follows.

Python Type

Encodes To XML Type

 

 

string

xsd:string

 

 

int

xsd:int

 

 

long

xsd:long

 

 

float

xsd:double

 

 

netsvc.Boolean

xsd:boolean

 

 

netsvc.Binary

xsd:base64Binary

 

 

netsvc.Date

xsd:date

 

 

netsvc.DateTime

xsd:dateTime

 

 

81

Page 81
Image 81
Python 7.0pl5, Python Manual manual Mapping of Scalar Types