From 69c5921fb2472f5cafa050dae088120ad17ed23a Mon Sep 17 00:00:00 2001 From: jsdelfino Date: Thu, 1 Jul 2010 06:04:47 +0000 Subject: Support user and email properties in WSGI integration. git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@959523 13f79535-47bb-0310-9956-ffa450edef68 --- sca-cpp/trunk/samples/store-gae/Makefile.am | 2 +- sca-cpp/trunk/samples/store-gae/app.yaml | 2 ++ .../trunk/samples/store-gae/domain-frontend.composite | 15 +++++---------- sca-cpp/trunk/samples/store-gae/domain-single.composite | 1 + sca-cpp/trunk/samples/store-gae/domain.composite | 1 + sca-cpp/trunk/samples/store-gae/htdocs/store.html | 16 +++++++++++++--- sca-cpp/trunk/samples/store-gae/shopping-cart.py | 12 ++++++++---- 7 files changed, 31 insertions(+), 18 deletions(-) (limited to 'sca-cpp/trunk/samples/store-gae') diff --git a/sca-cpp/trunk/samples/store-gae/Makefile.am b/sca-cpp/trunk/samples/store-gae/Makefile.am index 59a8b82ce7..98e5814dca 100644 --- a/sca-cpp/trunk/samples/store-gae/Makefile.am +++ b/sca-cpp/trunk/samples/store-gae/Makefile.am @@ -27,7 +27,7 @@ target.stamp: app.yaml *.py *.composite $(top_builddir)/modules/wsgi/*.py htdocs cp app.yaml *.py *.composite `ls $(top_builddir)/modules/wsgi/*.py | grep -v "\-test"` target mkdir -p target/htdocs cp -R htdocs/* target/htdocs - mkdir target/htdocs/js + mkdir -p target/htdocs/js cp -R $(top_builddir)/modules/server/htdocs/js/* target/htdocs/js touch target.stamp diff --git a/sca-cpp/trunk/samples/store-gae/app.yaml b/sca-cpp/trunk/samples/store-gae/app.yaml index e5807c233a..6a4e6a2fab 100644 --- a/sca-cpp/trunk/samples/store-gae/app.yaml +++ b/sca-cpp/trunk/samples/store-gae/app.yaml @@ -45,8 +45,10 @@ handlers: static_files: htdocs/\1 upload: htdocs/(.*\.(html|png)) secure: always + login: required - url: /.* script: composite.py secure: always + login: required diff --git a/sca-cpp/trunk/samples/store-gae/domain-frontend.composite b/sca-cpp/trunk/samples/store-gae/domain-frontend.composite index a183c84a76..f84b9ba500 100644 --- a/sca-cpp/trunk/samples/store-gae/domain-frontend.composite +++ b/sca-cpp/trunk/samples/store-gae/domain-frontend.composite @@ -27,15 +27,9 @@ - - - - - - - - - + + + @@ -49,7 +43,7 @@ - + @@ -58,6 +52,7 @@ + anonymous@example.com diff --git a/sca-cpp/trunk/samples/store-gae/domain-single.composite b/sca-cpp/trunk/samples/store-gae/domain-single.composite index ce9c601a32..2863838e18 100644 --- a/sca-cpp/trunk/samples/store-gae/domain-single.composite +++ b/sca-cpp/trunk/samples/store-gae/domain-single.composite @@ -50,6 +50,7 @@ + anonymous@example.com diff --git a/sca-cpp/trunk/samples/store-gae/domain.composite b/sca-cpp/trunk/samples/store-gae/domain.composite index ce9c601a32..2863838e18 100644 --- a/sca-cpp/trunk/samples/store-gae/domain.composite +++ b/sca-cpp/trunk/samples/store-gae/domain.composite @@ -50,6 +50,7 @@ + anonymous@example.com diff --git a/sca-cpp/trunk/samples/store-gae/htdocs/store.html b/sca-cpp/trunk/samples/store-gae/htdocs/store.html index 4e2ee6795a..d52dd1adaf 100644 --- a/sca-cpp/trunk/samples/store-gae/htdocs/store.html +++ b/sca-cpp/trunk/samples/store-gae/htdocs/store.html @@ -51,8 +51,14 @@ } document.getElementById('catalog').innerHTML=catalog; catalogItems = items; - - shoppingTotal.apply("gettotal", shoppingTotal_gettotalResponse); + } + + function shoppingCart_getemailResponse(email, exception) { + if(exception) { + alert(exception.message); + return; + } + document.getElementById('email').innerHTML = email; } function shoppingCart_getResponse(feed) { @@ -76,6 +82,8 @@ } } } + + shoppingTotal.apply("gettotal", shoppingTotal_gettotalResponse); } function shoppingTotal_gettotalResponse(total,exception) { @@ -132,6 +140,7 @@ try { catalog.apply("getcatalog", catalog_getcatalogResponse); + shoppingCart.apply("getemail", shoppingCart_getemailResponse); shoppingCart.get("", shoppingCart_getResponse); } catch(e){ @@ -145,6 +154,7 @@

Store

+

You're signed in as:
Sign out

Catalog

@@ -155,7 +165,7 @@
-

Your Shopping Cart

+

Your Shopping Cart


diff --git a/sca-cpp/trunk/samples/store-gae/shopping-cart.py b/sca-cpp/trunk/samples/store-gae/shopping-cart.py index d124ce8517..04ad729585 100644 --- a/sca-cpp/trunk/samples/store-gae/shopping-cart.py +++ b/sca-cpp/trunk/samples/store-gae/shopping-cart.py @@ -30,7 +30,7 @@ def getcart(id, cache): return cart # Post a new item to the cart, create a new cart if necessary -def post(collection, item, cache): +def post(collection, item, cache, email): id = str(uuid.uuid1()) cart = ((item[0], id, item[2]),) + getcart(cartId, cache) cache("put", (cartId,), cart) @@ -46,13 +46,13 @@ def find(id, cart): return find(id, cart[1:]) # Get items from the cart -def get(id, cache): +def get(id, cache, email): if id == (): return ("Your Cart", cartId) + getcart(cartId, cache) return find(id[0], getcart(cartId, cache)) # Delete items from the cart -def delete(id, cache): +def delete(id, cache, email): if id == (): return cache("delete", (cartId,)) return True @@ -68,7 +68,11 @@ def sum(items): return price(items[0]) + sum(items[1:]) # Return the total price of the items in the cart -def gettotal(cache): +def gettotal(cache, email): cart = getcart(cartId, cache) return sum(cart) +# Return the email of the cart owner +def getemail(cache, email): + return email() + -- cgit v1.2.3