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/Makefile.am2
-rw-r--r--sca-cpp/trunk/samples/store-gae/app.yaml2
-rw-r--r--sca-cpp/trunk/samples/store-gae/domain-frontend.composite15
-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/store.html16
-rw-r--r--sca-cpp/trunk/samples/store-gae/shopping-cart.py12
7 files changed, 31 insertions, 18 deletions
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 @@
<service name="Widget">
<t:binding.http uri="store"/>
</service>
- <reference name="catalog">
- <t:binding.http uri="https://sca-store-backend.appspot.com/catalog"/>
- </reference>
- <reference name="shoppingCart">
- <t:binding.http uri="https://sca-store-backend.appspot.com/shoppingCart"/>
- </reference>
- <reference name="shoppingTotal">
- <t:binding.http uri="https://sca-store-backend.appspot.com/shoppingCart"/>
- </reference>
+ <reference name="catalog" target="Catalog"/>
+ <reference name="shoppingCart" target="ShoppingCart/Cart"/>
+ <reference name="shoppingTotal" target="ShoppingCart/Total"/>
</component>
<component name="Catalog">
@@ -49,7 +43,7 @@
<component name="ShoppingCart">
<t:implementation.python script="shopping-cart.py"/>
- <service name="ShoppingCart">
+ <service name="Cart">
<t:binding.atom uri="shoppingCart"/>
</service>
<service name="Total">
@@ -58,6 +52,7 @@
<reference name="cache">
<t:binding.http uri="https://sca-store-backend.appspot.com/cache"/>
</reference>
+ <property name="email">anonymous@example.com</property>
</component>
<component name="CurrencyConverter">
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 @@
<t:binding.jsonrpc uri="total"/>
</service>
<reference name="cache" target="Cache"/>
+ <property name="email">anonymous@example.com</property>
</component>
<component name="CurrencyConverter">
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 @@
<t:binding.jsonrpc uri="total"/>
</service>
<reference name="cache" target="Cache"/>
+ <property name="email">anonymous@example.com</property>
</component>
<component name="CurrencyConverter">
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 @@
<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>
<div id="store">
<h2>Catalog</h2>
<form name="catalogForm">
@@ -155,7 +165,7 @@
<br>
- <h2>Your Shopping Cart</h2>
+ <h2>Your Shopping Cart</h2>
<form name="shoppingCartForm">
<div id="shoppingCart"></div>
<br>
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()
+