trashed the - empty anyway - 'slice' app;
[myslice.git] / engine / manifoldapi.py
1 # Manifold API Python interface
2 import xmlrpclib
3
4 from myslice.config import Config
5
6 debug=True
7
8 class ManifoldAPI:
9
10   def __init__(self, auth=None, cainfo=None):
11
12     config = Config()
13     self.auth = auth
14     self.server = config.manifold_server
15     self.port = config.manifold_port
16     self.path = config.manifold_path
17     self.cainfo = cainfo
18     self.errors = []
19     self.trace = []
20     self.calls = {}
21     self.multicall = False
22     self.url = config.manifold_url()
23     self.proxy = xmlrpclib.Server(self.url, verbose=False, allow_none=True)
24
25   def __getattr__(self, methodName):
26       def func(*args, **kwds):
27         result=getattr(self.proxy, methodName)(self.auth, *args, **kwds)
28         ### debug
29         if debug:
30           print '===> backend call',methodName, self.auth, self.url,'->',
31           if not result:                        print "no/empty result"
32           elif isinstance (result,str):         print "result is '%s'"%result
33           elif isinstance (result,list):        print "result is a %d-elts list"%len(result)
34           else:                                 print "dont know how to display result"
35         ###
36         return result
37       return func
38
39   # 4amine : xxx
40   def send_manifold_query (self, manifold_query):
41     (action,method)= (manifold_query.action,manifold_query.method)
42     if action=='get':
43       return self.proxy.Get(self.auth, method, manifold_query.filters, {}, manifold_query.fields)
44     # xxx...
45     elif action=='others':
46       return None
47
48