/[dgee]/dgee/pythonvm/dgeeinvoke.py
ViewVC logotype

Diff of /dgee/pythonvm/dgeeinvoke.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1 by ajmitch, Sun Jun 29 20:07:03 2003 UTC revision 1.2 by csmith, Sun Sep 21 10:36:02 2003 UTC
# Line 0  Line 1 
1    import sys, string, xmlrpclib
2    
3    def dyn_import(name):
4      try:
5        mod = __import__(name)
6        components = string.split(name, '.')
7        for comp in components[1:]:
8            mod = getattr(mod, comp)
9        return mod
10      except AttributeError, mesg:
11        raise ImportError, mesg
12    
13    
14    
15    
16    
17    class dgeeinvoke:
18    
19        def __init__(self):
20            print "Executing DGEE Wrapper"
21            pass
22    
23        def execute(self, **args):
24            if len(args) < 3:
25                raise "Not enough arguments to request handler"
26    
27    
28        def DGEE_run(self, dllName, className, methodName, params, *args):
29            ## load the webservice specified, instantiate the class, run the method
30            ## wrap the output
31            sys.path.append('/var/lib/dgee/data')
32            ## params is passed in as a tuple
33            
34            try:
35                wsName = dllName.split(".")[0]
36                obj = dyn_import('%s' % wsName)
37                #initialise block
38                wsClass = getattr(obj, className)
39                this = wsClass()
40                method = getattr(this, methodName)
41                # unpack params
42                print "params == %s" % `params`
43                result = apply(method,params)
44                return result
45                
46            except:
47                print "import failed"
48                err= """
49    Name:      %s
50    Value:     %s
51    Traceback  %s
52    """ % sys.exc_info()
53                print err
54                RunError= "RunError"
55                raise RunError,err
56            
57    
58    
59    def invokeDGEE(wsParam, wsName, wsClass, wsMethod, *args):
60        print "invokeDGEE called"
61        print """
62        -=- DGEE called with parameters:
63        wsParam:  %s
64        wsName:   %s
65        wsClass:  %s
66        wsMethod: %s
67    
68        """ % (wsParam, wsName, wsClass, wsMethod)
69    
70        params, method = xmlrpclib.loads(wsParam)
71        print params, method
72        dgi = dgeeinvoke()
73    
74        try:
75            response = dgi.DGEE_run(wsName, wsClass, wsMethod, params, () )
76            # wrap response in a singleton tuple
77            response = (response,)
78        except:
79            # report exception back to server
80            response = xmlrpclib.dumps(
81                xmlrpclib.Fault(1, "%s:%s" % (sys.exc_type, sys.exc_value))
82                )
83        else:
84            response = xmlrpclib.dumps(
85                response,
86                methodresponse=1
87                )
88    
89    
90    
91        print response
92        print "-=-=-=-=-=-"
93    
94        return response
95        
96        

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26