summaryrefslogtreecommitdiffstats
path: root/sca-cpp/trunk/samples/store-gae
diff options
context:
space:
mode:
Diffstat (limited to 'sca-cpp/trunk/samples/store-gae')
-rw-r--r--sca-cpp/trunk/samples/store-gae/domain-frontend.composite1
-rw-r--r--sca-cpp/trunk/samples/store-gae/domain-single.composite1
-rw-r--r--sca-cpp/trunk/samples/store-gae/domain.composite1
-rw-r--r--sca-cpp/trunk/samples/store-gae/htdocs/index.html11
-rw-r--r--sca-cpp/trunk/samples/store-gae/shopping-cart.py14
5 files changed, 22 insertions, 6 deletions
diff --git a/sca-cpp/trunk/samples/store-gae/domain-frontend.composite b/sca-cpp/trunk/samples/store-gae/domain-frontend.composite
index f84b9ba500..e7e10e2de1 100644
--- a/sca-cpp/trunk/samples/store-gae/domain-frontend.composite
+++ b/sca-cpp/trunk/samples/store-gae/domain-frontend.composite
@@ -52,6 +52,7 @@
<reference name="cache">
<t:binding.http uri="https://sca-store-backend.appspot.com/cache"/>
</reference>
+ <property name="host">localhost</property>
<property name="email">anonymous@example.com</property>
</component>
diff --git a/sca-cpp/trunk/samples/store-gae/domain-single.composite b/sca-cpp/trunk/samples/store-gae/domain-single.composite
index 2863838e18..4a5d53e695 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 @@
<t:binding.jsonrpc uri="total"/>
</service>
<reference name="cache" target="Cache"/>
+ <property name="host">localhost</property>
<property name="email">anonymous@example.com</property>
</component>
diff --git a/sca-cpp/trunk/samples/store-gae/domain.composite b/sca-cpp/trunk/samples/store-gae/domain.composite
index 2863838e18..4a5d53e695 100644
--- a/sca-cpp/trunk/samples/store-gae/domain.composite
+++ b/sca-cpp/trunk/samples/store-gae/domain.composite
@@ -50,6 +50,7 @@
<t:binding.jsonrpc uri="total"/>
</service>
<reference name="cache" target="Cache"/>
+ <property name="host">localhost</property>
<property name="email">anonymous@example.com</property>
</component>
diff --git a/sca-cpp/trunk/samples/store-gae/htdocs/index.html b/sca-cpp/trunk/samples/store-gae/htdocs/index.html
index e880285f23..2f61b1f946 100644
--- a/sca-cpp/trunk/samples/store-gae/htdocs/index.html
+++ b/sca-cpp/trunk/samples/store-gae/htdocs/index.html
@@ -51,6 +51,14 @@ function catalog_getcatalogResponse(items, exception) {
catalogItems = items;
}
+function shoppingCart_gethostResponse(host, exception) {
+ if (exception) {
+ alert(exception.message);
+ return;
+ }
+ document.getElementById('host').innerHTML = host;
+}
+
function shoppingCart_getemailResponse(email, exception) {
if (exception) {
alert(exception.message);
@@ -131,6 +139,7 @@ function init() {
try {
catalog.apply("getcatalog", catalog_getcatalogResponse);
shoppingCart.apply("getemail", shoppingCart_getemailResponse);
+ shoppingCart.apply("gethost", shoppingCart_gethostResponse);
shoppingCart.get("", shoppingCart_getResponse);
} catch(e){
alert(e);
@@ -141,7 +150,7 @@ function init() {
<body onload="init()">
<h1>Store</h1>
-<p>You're signed in as: <span id="email"></span><br/><a href="/_ah/login?continue=/store.html&action=Logout">Sign out</a></p>
+<p>Welcome to: <span id="host"></span>, you're signed in as: <span id="email"></span><br/><a href="/logout">Sign out</a></p>
<div id="store">
<h2>Catalog</h2>
<form name="catalogForm">
diff --git a/sca-cpp/trunk/samples/store-gae/shopping-cart.py b/sca-cpp/trunk/samples/store-gae/shopping-cart.py
index 04ad729585..8d369e3315 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, email):
+def post(collection, item, cache, host, 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, email):
+def get(id, cache, host, 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, email):
+def delete(id, cache, host, email):
if id == ():
return cache("delete", (cartId,))
return True
@@ -68,11 +68,15 @@ def sum(items):
return price(items[0]) + sum(items[1:])
# Return the total price of the items in the cart
-def gettotal(cache, email):
+def gettotal(cache, host, email):
cart = getcart(cartId, cache)
return sum(cart)
# Return the email of the cart owner
-def getemail(cache, email):
+def getemail(cache, host, email):
return email()
+# Return the host that the app is running on
+def gethost(cache, host, email):
+ return host()
+