Permalink
Browse files

pmt rpc can traverse dotted name list

  • Loading branch information...
1 parent 90cc6b6 commit 8f33f16525ace07e9f97664ffa27b1ed01e396d8 @guruofquality committed Oct 3, 2012
Showing with 10 additions and 2 deletions.
  1. +10 −2 python/pmt_rpc.py
View
@@ -80,10 +80,18 @@ def handle_request(self, fcn_name, request):
err = 'cannot parse request for %s, expected tuple of args, kwargs'%fcn_name
return request, None, err
+ #fly through dots to get the fcn pointer
+ try:
+ fcn_ptr = self._obj
+ for name in fcn_name.split('.'):
+ fcn_ptr = getattr(fcn_ptr, name)
+ except:
+ err = 'cannot find function %s in %s'%(fcn_name, self._obj)
+ return request, None, err
+
#try to execute the request
try:
- fcn = getattr(self._obj, fcn_name)
- ret = fcn(*args, **kwargs)
+ ret = fcn_ptr(*args, **kwargs)
except:
err = 'cannot execute request for %s, expected tuple of args, kwargs'%fcn_name
return request, None, err

0 comments on commit 8f33f16

Please sign in to comment.