From babcd818b2799218ba4a9ed2226362b16ea41de8 Mon Sep 17 00:00:00 2001 From: jsdelfino Date: Tue, 24 Aug 2010 01:10:32 +0000 Subject: Add support for properties. git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@988366 13f79535-47bb-0310-9956-ffa450edef68 --- .../src/main/resources/invoker.py | 29 ++++++++++++++++++---- 1 file changed, 24 insertions(+), 5 deletions(-) (limited to 'sca-java-2.x/trunk/modules/implementation-python-runtime/src/main/resources') diff --git a/sca-java-2.x/trunk/modules/implementation-python-runtime/src/main/resources/invoker.py b/sca-java-2.x/trunk/modules/implementation-python-runtime/src/main/resources/invoker.py index 730e7c483f..48107671d6 100644 --- a/sca-java-2.x/trunk/modules/implementation-python-runtime/src/main/resources/invoker.py +++ b/sca-java-2.x/trunk/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) + -- cgit v1.2.3