def _PackForSuds(obj, factory):
 if (obj in ({}, None)):
  return suds.null()
 elif isinstance(obj, dict):
  if ('xsi_type' in obj):
   try:
    new_obj = factory.create(obj['xsi_type'])
   except suds.TypeNotFound:
    new_obj = factory.create(':'.join(['ns0', obj['xsi_type']]))
   for (param, _) in new_obj:
    if param.endswith('.Type'):
     setattr(new_obj, param, obj['xsi_type'])
    else:
     setattr(new_obj, param, None)
   for key in obj:
    if (key == 'xsi_type'):
     continue
    setattr(new_obj, key, _PackForSuds(obj[key], factory))
  else:
   new_obj = {}
   for key in obj:
    new_obj[key] = _PackForSuds(obj[key], factory)
  return new_obj
 elif isinstance(obj, (list, tuple)):
  return [_PackForSuds(item, factory) for item in obj]
 else:
  _RecurseOverObject(obj, factory)
  return obj

def _PackForSuds ( obj , factory ) : if ( obj in ( { } , None ) ) : return suds . null ( ) elif isinstance ( obj , dict ) : if ( 'xsi_type' in obj ) : try : new_obj = factory . create ( obj [ 'xsi_type' ] ) except suds . TypeNotFound : new_obj = factory . create ( ':' . join ( [ 'ns0' , obj [ 'xsi_type' ] ] ) ) for ( param , _ ) in new_obj : if param . endswith ( '.Type' ) : setattr ( new_obj , param , obj [ 'xsi_type' ] ) else : setattr ( new_obj , param , None ) for key in obj : if ( key == 'xsi_type' ) : continue setattr ( new_obj , key , _PackForSuds ( obj [ key ] , factory ) ) else : new_obj = { } for key in obj : new_obj [ key ] = _PackForSuds ( obj [ key ] , factory ) return new_obj elif isinstance ( obj , ( list , tuple ) ) : return [ _PackForSuds ( item , factory ) for item in obj ] else : _RecurseOverObject ( obj , factory ) return obj
packs soap input into the format we want for suds .