diff options
author | jsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68> | 2010-07-20 04:36:16 +0000 |
---|---|---|
committer | jsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68> | 2010-07-20 04:36:16 +0000 |
commit | c857c88725bbc79edd9edd0ae86fda557bdf85b2 (patch) | |
tree | 2b9217dc2a60917d819c20aca9508cc59946181f /sandbox/sebastien/java/dynamic/modules/implementation-python-runtime/src/main/resources | |
parent | 08f6c248d0716a98504e28341c44704ab5f90821 (diff) |
Add support for properties.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@965722 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sandbox/sebastien/java/dynamic/modules/implementation-python-runtime/src/main/resources')
-rw-r--r-- | sandbox/sebastien/java/dynamic/modules/implementation-python-runtime/src/main/resources/invoker.py | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/sandbox/sebastien/java/dynamic/modules/implementation-python-runtime/src/main/resources/invoker.py b/sandbox/sebastien/java/dynamic/modules/implementation-python-runtime/src/main/resources/invoker.py index 730e7c483f..48107671d6 100644 --- a/sandbox/sebastien/java/dynamic/modules/implementation-python-runtime/src/main/resources/invoker.py +++ b/sandbox/sebastien/java/dynamic/modules/implementation-python-runtime/src/main/resources/invoker.py @@ -52,19 +52,37 @@ def mkproxies(jpx): return () return cons(proxy(car(jpx)), mkproxies(cdr(jpx))) +class prop: + def __init__(self, jpy): + self.jpy = jpy + + def __call__(self): + # Eval the property + res = self.jpy.eval() + return res + +def __repr__(self): + return repr((jpy,)) + +def mkprops(jpy): + if isNil(jpy): + return () + return cons(prop(car(jpy)), mkprops(cdr(jpy))) + # Make a callable component class component: - def __init__(self, name, impl, jpx): + def __init__(self, name, impl, jpx, jpy): self.name = name self.impl = impl[0:len(impl) - 3] self.mod = __import__(self.impl) self.proxies = mkproxies(jpx) + self.props = mkprops(jpy) def __call__(self, func, *args): - return self.mod.__getattribute__(func)(*(args + self.proxies)) + return self.mod.__getattribute__(func)(*(args + self.proxies + self.props)) def __repr__(self): - return repr((self.name, self.impl, self.mod, self.svcs, self.refs, self.props, self.proxies)) + return repr((self.name, self.impl, self.mod, self.props, self.proxies)) # Converts the args received in a JSON request to a list of key value pairs def jsonArgs(a): @@ -84,6 +102,7 @@ def apply(jsreq, comp): return jsonResult(jid, v)[0] # Make a component that can be called with a JSON function request -def mkcomponent(name, impl, jpx): - comp = component(name, impl, jpx) +def mkcomponent(name, impl, jpx, jpy): + comp = component(name, impl, jpx, jpy) return lambda jsreq: apply(jsreq, comp) + |