From a2a2cb76e9582af32b6803be7fa99af074dc04ae Mon Sep 17 00:00:00 2001 From: jsdelfino Date: Mon, 25 Oct 2010 03:18:16 +0000 Subject: Support python method invocation style on references, ref.func(...) in addition to ref('func', ...). Minor cleanup of the various samples, renamed gettotal to total and getcatalog to items, for consistency with the python sample. git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1026939 13f79535-47bb-0310-9956-ffa450edef68 --- .../samples/store-cluster/domains/jane/shopping-cart.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'sca-cpp/trunk/samples/store-cluster/domains/jane/shopping-cart.py') diff --git a/sca-cpp/trunk/samples/store-cluster/domains/jane/shopping-cart.py b/sca-cpp/trunk/samples/store-cluster/domains/jane/shopping-cart.py index e315b2f1ca..44484ea5d2 100644 --- a/sca-cpp/trunk/samples/store-cluster/domains/jane/shopping-cart.py +++ b/sca-cpp/trunk/samples/store-cluster/domains/jane/shopping-cart.py @@ -21,12 +21,12 @@ import sys # Convert a particular host and user email to a cart id def cartid(host, email): - return ("cart", host(), email()) + return ("cart", host.eval(), email.eval()) # Get the shopping cart from the cache # Return an empty cart if not found def getcart(id, cache): - cart = cache("get", id) + cart = cache.get(id) if cart is None: return () return cart @@ -35,7 +35,7 @@ def getcart(id, cache): def post(collection, item, cache, host, email): id = str(uuid.uuid1()) cart = ((item[0], id, item[2]),) + getcart(cartid(host, email), cache) - cache("put", cartid(host, email), cart) + cache.put(cartid(host, email), cart) return (id,) @@ -51,13 +51,13 @@ def find(id, cart): # Get items from the cart def get(id, cache, host, email): if id == (): - return ("Your Cart", email()) + getcart(cartid(host, email), cache) + return ("Your Cart", email.eval()) + getcart(cartid(host, email), cache) return find(id[0], getcart(cartid(host, email), cache)) # Delete items from the cart def delete(id, cache, host, email): if id == (): - return cache("delete", cartid(host, email)) + return cache.delete(cartid(host, email)) return True # Return the price of an item @@ -71,6 +71,6 @@ def sum(items): return price(items[0]) + sum(items[1:]) # Return the total price of the items in the cart -def gettotal(cache, host, email): +def total(cache, host, email): return sum(getcart(cartid(host, email), cache)) -- cgit v1.2.3