- self.url = ConfigEngine().manifold_url()
- self.server = xmlrpclib.Server(self.url, verbose=False, allow_none=True)
-
- def __repr__ (self): return "ManifoldAPI[%s]"%self.url
-
- def _print_value (self, value):
- print "+++",'value',
- if isinstance (value,list): print "[%d]"%len(value),
- elif isinstance (value,dict): print "{%d}"%len(value),
- print mytruncate (value,80)
-
- # a one-liner to give a hint of what the return value looks like
- def _print_result (self, result):
- 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)
- elif isinstance (result,dict):
- print "result is a dict with %d keys : %s"%(len(result),result.keys())
- for (k,v) in result.iteritems():
- if v is None: continue
- if k=='value': self._print_value(v)
- else: print '+++',k,':',mytruncate (v,30)
- else: print "[dont know how to display result] %s"%result
-
- # how to display a call
- def _repr_query (self,methodName, query):
- try: action=query['action']
- except: action="???"
- try: subject=query['object']
- except: subject="???"
- # most of the time, we run 'forward'
- if methodName=='forward': return "forward(%s(%s))"%(action,subject)
- else: return "%s(%s)"%(action,subject)
+ self.url = config.manifold_url()
+
+ # Manifold uses a self signed certificate
+ # https://www.python.org/dev/peps/pep-0476/
+ if hasattr(ssl, '_create_unverified_context'):
+ self.server = xmlrpclib.Server(self.url, verbose=False, allow_none=True,
+ context=ssl._create_unverified_context())
+ else :
+ self.server = xmlrpclib.Server(self.url, verbose=False, allow_none=True)