- print '===> backend call',methodName, self.auth, self.url,'->',
- if not result: print "[no/empty result]"
- elif isinstance (result,str): print "result is '%s'"%result
- elif isinstance (result,list): print "result is a %d-elts list"%len(result)
- else: print "[dont know how to display result]"
- return ManifoldResult (code=ManifoldCode.SUCCESS, value=result)
+ print '<==== backend call %s(*%s,**%s) returned'%(methodName,args,kwds),
+ print '.ctd. Authmethod=',self.auth['AuthMethod'], self.url,'->',
+ self._print_result(result)
+ ### attempt to cope with old APIs and new APIs
+ if isinstance (result, dict) and 'code' in result:
+ if debug: print "taken as new API"
+ # this sounds like a result from a new API
+ # minimal treatment is required, but we do want to turn this into a
+ # class instance
+ if result['code'] != 2: # in the manifold world, this can be either
+ # 0 (ok) 1 (partial result) or 2 (which means error)
+ if debug: print "OK (new API)"
+ return ManifoldResult(code=result['code'], value=result['value'])
+ else:
+ if debug: print "KO (new API) - raising ManifoldException"
+ raise ManifoldException(ManifoldResult(code=result['code'], output=result['description']))
+ else:
+ if debug: print "taken as old API"
+ # we're talking to an old API
+ # so if we make it here it should mean success
+ return ManifoldResult (code=ManifoldCode.SUCCESS, value=result)