# HG changeset patch # User Nicolas Chauvat # Date 1297934810 -3600 # Node ID 29f085f6177b973584c5114b49c786fa03f46608 # Parent c53aa19640b2c954b8cb96df9a1b42e7574dc445 [sobjects/parsers] compatibility with xml view of cw <= 3.10 diff -r c53aa19640b2 -r 29f085f6177b sobjects/parsers.py --- a/sobjects/parsers.py Thu Feb 17 10:24:45 2011 +0100 +++ b/sobjects/parsers.py Thu Feb 17 10:26:50 2011 +0100 @@ -46,6 +46,8 @@ return todate(datetime.strptime(ustr, '%Y-%m-%d')) DEFAULT_CONVERTERS['Date'] = convert_date def convert_datetime(ustr): + if '.' in ustr: # assume %Y-%m-%d %H:%M:%S.mmmmmm + ustr = ustr.split('.',1)[0] return datetime.strptime(ustr, '%Y-%m-%d %H:%M:%S') DEFAULT_CONVERTERS['Datetime'] = convert_datetime def convert_time(ustr): @@ -76,10 +78,17 @@ def _entity_etree(parent): for node in list(parent): - item = {'cwtype': unicode(node.tag), - 'cwuri': node.attrib['cwuri'], - 'eid': typed_eid(node.attrib['eid']), - } + try: + item = {'cwtype': unicode(node.tag), + 'cwuri': node.attrib['cwuri'], + 'eid': typed_eid(node.attrib['eid']), + } + except KeyError: + # cw < 3.11 compat mode XXX + item = {'cwtype': unicode(node.tag), + 'cwuri': node.find('cwuri').text, + 'eid': typed_eid(node.find('eid').text), + } rels = {} for child in node: role = child.get('role')