Exemplo n.º 1
0
def xml_rec(value, key):
    if isinstance(value, (dict, Storage)):
        return TAG[key](*[TAG[k](xml_rec(v, '')) for k, v in value.items()])
    elif isinstance(value, list):
        return TAG[key](*[TAG.item(xml_rec(item, '')) for item in value])
    elif value == None:
        return 'None'
    elif isinstance(value,unicode):
        return value.encode('utf-8')
    else:
        return str(value)
Exemplo n.º 2
0
def xml_rec(value, key):
    if isinstance(value, (dict, Storage)):
        return TAG[key](*[TAG[k](xml_rec(v, '')) for k, v in value.items()])
    elif isinstance(value, list):
        return TAG[key](*[TAG.item(xml_rec(item, '')) for item in value])
    elif value == None:
        return 'None'
    elif isinstance(value, unicode):
        return value.encode('utf-8')
    else:
        return str(value)
Exemplo n.º 3
0
def xml_rec(value, key):
    if hasattr(value,'custom_xml') and callable(value.custom_xml):
        return value.custom_xml()
    elif isinstance(value, (dict, Storage)):
        return TAG[key](*[TAG[k](xml_rec(v, '')) for k, v in value.items()])
    elif isinstance(value, list):
        return TAG[key](*[TAG.item(xml_rec(item, '')) for item in value])
    elif hasattr(value,'as_list') and callable(value.as_list):
        return str(xml_rec(value.as_list(),''))
    elif hasattr(value,'as_dict') and callable(value.as_dict):
        return str(xml_rec(value.as_dict(),''))
    else:
        return xmlescape(value)
Exemplo n.º 4
0
def xml_rec(value, key):
    if hasattr(value,'custom_xml') and callable(value.custom_xml):
        return value.custom_xml()
    elif isinstance(value, (dict, Storage)):
        return TAG[key](*[TAG[k](xml_rec(v, '')) for k, v in value.items()])
    elif isinstance(value, list):
        return TAG[key](*[TAG.item(xml_rec(item, '')) for item in value])
    elif hasattr(value,'as_list') and callable(value.as_list):
        return str(xml_rec(value.as_list(),''))
    elif hasattr(value,'as_dict') and callable(value.as_dict):
        return str(xml_rec(value.as_dict(),''))
    else:
        return xmlescape(value)
Exemplo n.º 5
0
def xml_rec(value, key, quote=True):
    if hasattr(value, "custom_xml") and callable(value.custom_xml):
        return value.custom_xml()
    elif isinstance(value, (dict, Storage)):
        return TAG[key](*[TAG[k](xml_rec(v, "", quote)) for k, v in value.items()])
    elif isinstance(value, list):
        return TAG[key](*[TAG.item(xml_rec(item, "", quote)) for item in value])
    elif hasattr(value, "as_list") and callable(value.as_list):
        return str(xml_rec(value.as_list(), "", quote))
    elif hasattr(value, "as_dict") and callable(value.as_dict):
        return str(xml_rec(value.as_dict(), "", quote))
    else:
        return xmlescape(value, quote)