diff options
author | jsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68> | 2011-03-08 08:18:07 +0000 |
---|---|---|
committer | jsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68> | 2011-03-08 08:18:07 +0000 |
commit | 49b878b1b0f2e52bbd5282c22ac32a68e1e8736c (patch) | |
tree | 1eb26926f9d703c61b329a0f07178090b57cd55d /sca-cpp/trunk/samples | |
parent | 5b33dc5c5a87fff146951ca0543bf558454c331d (diff) |
Change ATOM and RSS feed representations to use name value pairs instead of just strings, to allow support for all ATOM and RSS attributes and avoid confusion with non-feed string results.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1079292 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-cpp/trunk/samples')
22 files changed, 148 insertions, 92 deletions
diff --git a/sca-cpp/trunk/samples/store-cluster/domains/jane/htdocs/index.html b/sca-cpp/trunk/samples/store-cluster/domains/jane/htdocs/index.html index 4cd219bc9c..09e2c4ab83 100644 --- a/sca-cpp/trunk/samples/store-cluster/domains/jane/htdocs/index.html +++ b/sca-cpp/trunk/samples/store-cluster/domains/jane/htdocs/index.html @@ -22,8 +22,12 @@ <meta name="apple-mobile-web-app-capable" content="yes"/>
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent"/>
<link rel="stylesheet" type="text/css" href="/ui.css"/>
-<title>Store</title>
+<title>Jane's Store</title>
+<script type="text/javascript" src="/util.js"></script>
+<script type="text/javascript" src="/elemutil.js"></script>
+<script type="text/javascript" src="/xmlutil.js"></script>
+<script type="text/javascript" src="/atomutil.js"></script>
<script type="text/javascript" src="/component.js"></script>
<script type="text/javascript">
@@ -50,8 +54,9 @@ function catalog_itemsResponse(items, exception) { }
-function shoppingCart_getResponse(feed) {
- if (feed != null) {
+function shoppingCart_getResponse(doc) {
+ if (doc != null) {
+ var feed = parseXML([doc]);
var entries = feed.getElementsByTagName("entry");
var list = "";
for (var i=0; i<entries.length; i++) {
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 44484ea5d2..b3818a6727 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 @@ -34,7 +34,7 @@ def getcart(id, cache): # Post a new item to the cart, create a new cart if necessary def post(collection, item, cache, host, email): id = str(uuid.uuid1()) - cart = ((item[0], id, item[2]),) + getcart(cartid(host, email), cache) + cart = (("'entry", item[0][1], ("'id", id), item[0][3]),) + getcart(cartid(host, email), cache) cache.put(cartid(host, email), cart) return (id,) @@ -42,16 +42,16 @@ def post(collection, item, cache, host, email): # Find an item in the cart def find(id, cart): if cart == (): - return ("Item", "0", ()) - elif id == cart[0][1]: - return cart[0] + return (("'entry", ("'title", "Item"), ("'id", 0)),) + elif id == cart[0][2][1]: + return (cart[0],) else: return find(id, cart[1:]) # Get items from the cart def get(id, cache, host, email): if id == (): - return ("Your Cart", email.eval()) + getcart(cartid(host, email), cache) + return ((("'feed", ("'title", "Your Cart"), ("'id", email.eval())) + getcart(cartid(host,email), cache)),) return find(id[0], getcart(cartid(host, email), cache)) # Delete items from the cart @@ -62,7 +62,7 @@ def delete(id, cache, host, email): # Return the price of an item def price(item): - return float(filter(lambda x: x[0] == "'price", item[2])[0][1]) + return float(filter(lambda x: x[0] == "'price", item[3][1][1:])[0][1]) # Sum the prices of a list of items def sum(items): diff --git a/sca-cpp/trunk/samples/store-cluster/domains/joe/htdocs/index.html b/sca-cpp/trunk/samples/store-cluster/domains/joe/htdocs/index.html index c32dcd9d53..4a25ff4afa 100644 --- a/sca-cpp/trunk/samples/store-cluster/domains/joe/htdocs/index.html +++ b/sca-cpp/trunk/samples/store-cluster/domains/joe/htdocs/index.html @@ -22,8 +22,12 @@ <meta name="apple-mobile-web-app-capable" content="yes"/>
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent"/>
<link rel="stylesheet" type="text/css" href="/ui.css"/>
-<title>Store</title>
+<title>Joe's Store</title>
+<script type="text/javascript" src="/util.js"></script>
+<script type="text/javascript" src="/elemutil.js"></script>
+<script type="text/javascript" src="/xmlutil.js"></script>
+<script type="text/javascript" src="/atomutil.js"></script>
<script type="text/javascript" src="/component.js"></script>
<script type="text/javascript">
@@ -50,8 +54,9 @@ function catalog_itemsResponse(items, exception) { }
-function shoppingCart_getResponse(feed) {
- if (feed != null) {
+function shoppingCart_getResponse(doc) {
+ if (doc != null) {
+ var feed = parseXML([doc]);
var entries = feed.getElementsByTagName("entry");
var list = "";
for (var i=0; i<entries.length; i++) {
diff --git a/sca-cpp/trunk/samples/store-cluster/domains/joe/shopping-cart.py b/sca-cpp/trunk/samples/store-cluster/domains/joe/shopping-cart.py index 44484ea5d2..b3818a6727 100644 --- a/sca-cpp/trunk/samples/store-cluster/domains/joe/shopping-cart.py +++ b/sca-cpp/trunk/samples/store-cluster/domains/joe/shopping-cart.py @@ -34,7 +34,7 @@ def getcart(id, cache): # Post a new item to the cart, create a new cart if necessary def post(collection, item, cache, host, email): id = str(uuid.uuid1()) - cart = ((item[0], id, item[2]),) + getcart(cartid(host, email), cache) + cart = (("'entry", item[0][1], ("'id", id), item[0][3]),) + getcart(cartid(host, email), cache) cache.put(cartid(host, email), cart) return (id,) @@ -42,16 +42,16 @@ def post(collection, item, cache, host, email): # Find an item in the cart def find(id, cart): if cart == (): - return ("Item", "0", ()) - elif id == cart[0][1]: - return cart[0] + return (("'entry", ("'title", "Item"), ("'id", 0)),) + elif id == cart[0][2][1]: + return (cart[0],) else: return find(id, cart[1:]) # Get items from the cart def get(id, cache, host, email): if id == (): - return ("Your Cart", email.eval()) + getcart(cartid(host, email), cache) + return ((("'feed", ("'title", "Your Cart"), ("'id", email.eval())) + getcart(cartid(host,email), cache)),) return find(id[0], getcart(cartid(host, email), cache)) # Delete items from the cart @@ -62,7 +62,7 @@ def delete(id, cache, host, email): # Return the price of an item def price(item): - return float(filter(lambda x: x[0] == "'price", item[2])[0][1]) + return float(filter(lambda x: x[0] == "'price", item[3][1][1:])[0][1]) # Sum the prices of a list of items def sum(items): diff --git a/sca-cpp/trunk/samples/store-cpp/htdocs/index.html b/sca-cpp/trunk/samples/store-cpp/htdocs/index.html index 79996c6853..83b1e16df4 100644 --- a/sca-cpp/trunk/samples/store-cpp/htdocs/index.html +++ b/sca-cpp/trunk/samples/store-cpp/htdocs/index.html @@ -24,6 +24,10 @@ <link rel="stylesheet" type="text/css" href="/ui.css"/>
<title>Store</title>
+<script type="text/javascript" src="/util.js"></script>
+<script type="text/javascript" src="/elemutil.js"></script>
+<script type="text/javascript" src="/xmlutil.js"></script>
+<script type="text/javascript" src="/atomutil.js"></script>
<script type="text/javascript" src="/component.js"></script>
<script type="text/javascript">
@@ -50,8 +54,9 @@ function catalog_itemsResponse(items, exception) { }
-function shoppingCart_getResponse(feed) {
- if (feed != null) {
+function shoppingCart_getResponse(doc) {
+ if (doc != null) {
+ var feed = parseXML([doc]);
var entries = feed.getElementsByTagName("entry");
var list = "";
for (var i=0; i<entries.length; i++) {
diff --git a/sca-cpp/trunk/samples/store-cpp/shopping-cart.cpp b/sca-cpp/trunk/samples/store-cpp/shopping-cart.cpp index 738ab2f4c7..4b5dc8db6b 100644 --- a/sca-cpp/trunk/samples/store-cpp/shopping-cart.cpp +++ b/sca-cpp/trunk/samples/store-cpp/shopping-cart.cpp @@ -55,7 +55,7 @@ const list<value> getcart(const value& id, const lambda<value(const list<value>& */ const failable<value> post(unused const list<value>& collection, const value& item, const lambda<value(const list<value>&)> cache) { const value id(mkuuid()); - const list<value> newItem(mklist<value>(car<value>(item), id, caddr<value>(item))); + const list<value> newItem(mklist<value>("entry", cadr<value>(car<value>(item)), mklist<value>("id", id), cadddr<value>(car<value>(item)))); const list<value> cart(cons<value>(newItem, getcart(cartId, cache))); cache(mklist<value>("put", mklist<value>(cartId), cart)); return value(mklist<value>(id)); @@ -66,9 +66,9 @@ const failable<value> post(unused const list<value>& collection, const value& it */ const value find(const value& id, const list<value>& cart) { if (isNil(cart)) - return cons<value>(string("Item"), mklist<value>("0", list<value>())); - if (id == cadr<value>(car(cart))) - return car(cart); + return mklist<value>(mklist<value>("entry", mklist<value>("title", string("Item")), mklist<value>("id", "0"))); + if (id == cadr<value>(caddr<value>(car(cart)))) + return mklist<value>(car(cart)); return find(id, cdr(cart)); } @@ -77,7 +77,7 @@ const value find(const value& id, const list<value>& cart) { */ const failable<value> get(const list<value>& id, const lambda<value(const list<value>&)> cache) { if (isNil(id)) - return value(append(mklist<value>(string("Your Cart"), cartId), getcart(cartId, cache))); + return value(mklist<value>(append(mklist<value>("feed", mklist<value>("title", string("Your Cart")), mklist<value>("id", cartId)), getcart(cartId, cache)))); return find(car(id), getcart(cartId, cache)); } @@ -94,7 +94,7 @@ const failable<value> del(const list<value>& id, unused const lambda<value(const * Return the price of an item. */ const double price(const list<value>& item) { - return cadr<value>(assoc<value>("price", caddr(item))); + return cadr<value>(assoc<value>("price", cdr<value>(cadr<value>(cadddr(item))))); } /** diff --git a/sca-cpp/trunk/samples/store-gae/htdocs/index.html b/sca-cpp/trunk/samples/store-gae/htdocs/index.html index d4884cf4d5..e16890eee4 100644 --- a/sca-cpp/trunk/samples/store-gae/htdocs/index.html +++ b/sca-cpp/trunk/samples/store-gae/htdocs/index.html @@ -24,6 +24,10 @@ <link rel="stylesheet" type="text/css" href="/ui.css"/>
<title>Store</title>
+<script type="text/javascript" src="/util.js"></script>
+<script type="text/javascript" src="/elemutil.js"></script>
+<script type="text/javascript" src="/xmlutil.js"></script>
+<script type="text/javascript" src="/atomutil.js"></script>
<script type="text/javascript" src="/component.js"></script>
<script type="text/javascript">
@@ -65,8 +69,9 @@ function shoppingCart_emailResponse(email, exception) { document.getElementById('email').innerHTML = email;
}
-function shoppingCart_getResponse(feed) {
- if (feed != null) {
+function shoppingCart_getResponse(doc) {
+ if (doc != null) {
+ var feed = parseXML([doc]);
var entries = feed.getElementsByTagName("entry");
var list = "";
for (var i=0; i<entries.length; i++) {
diff --git a/sca-cpp/trunk/samples/store-gae/shopping-cart.py b/sca-cpp/trunk/samples/store-gae/shopping-cart.py index 3c3168d77b..11a55a552a 100644 --- a/sca-cpp/trunk/samples/store-gae/shopping-cart.py +++ b/sca-cpp/trunk/samples/store-gae/shopping-cart.py @@ -32,23 +32,23 @@ def getcart(id, cache): # Post a new item to the cart, create a new cart if necessary def post(collection, item, cache, host, email): id = str(uuid.uuid1()) - cart = ((item[0], id, item[2]),) + getcart(cartId, cache) + cart = (("'entry", item[0][1], ("'id", id), item[0][3]),) + getcart(cartId, cache) cache.put((cartId,), cart) return (id,) # Find an item in the cart def find(id, cart): if cart == (): - return ("Item", "0", ()) - elif id == cart[0][1]: - return cart[0] + return (("'entry", ("'title", "Item"), ("'id", 0)),) + elif id == cart[0][2][1]: + return (cart[0],) else: return find(id, cart[1:]) # Get items from the cart def get(id, cache, host, email): if id == (): - return ("Your Cart", cartId) + getcart(cartId, cache) + return ((("'feed", ("'title", "Your Cart"), ("'id", cartId)) + getcart(cartId, cache)),) return find(id[0], getcart(cartId, cache)) # Delete items from the cart @@ -59,7 +59,7 @@ def delete(id, cache, host, email): # Return the price of an item def price(item): - return float(filter(lambda x: x[0] == "'price", item[2])[0][1]) + return float(filter(lambda x: x[0] == "'price", item[3][1][1:])[0][1]) # Sum the prices of a list of items def sum(items): diff --git a/sca-cpp/trunk/samples/store-java/htdocs/index.html b/sca-cpp/trunk/samples/store-java/htdocs/index.html index 79996c6853..83b1e16df4 100644 --- a/sca-cpp/trunk/samples/store-java/htdocs/index.html +++ b/sca-cpp/trunk/samples/store-java/htdocs/index.html @@ -24,6 +24,10 @@ <link rel="stylesheet" type="text/css" href="/ui.css"/>
<title>Store</title>
+<script type="text/javascript" src="/util.js"></script>
+<script type="text/javascript" src="/elemutil.js"></script>
+<script type="text/javascript" src="/xmlutil.js"></script>
+<script type="text/javascript" src="/atomutil.js"></script>
<script type="text/javascript" src="/component.js"></script>
<script type="text/javascript">
@@ -50,8 +54,9 @@ function catalog_itemsResponse(items, exception) { }
-function shoppingCart_getResponse(feed) {
- if (feed != null) {
+function shoppingCart_getResponse(doc) {
+ if (doc != null) {
+ var feed = parseXML([doc]);
var entries = feed.getElementsByTagName("entry");
var list = "";
for (var i=0; i<entries.length; i++) {
diff --git a/sca-cpp/trunk/samples/store-java/store/ShoppingCartImpl.java b/sca-cpp/trunk/samples/store-java/store/ShoppingCartImpl.java index e51beacc20..bd7678cce7 100644 --- a/sca-cpp/trunk/samples/store-java/store/ShoppingCartImpl.java +++ b/sca-cpp/trunk/samples/store-java/store/ShoppingCartImpl.java @@ -47,7 +47,7 @@ public class ShoppingCartImpl { */ public Iterable<String> post(final Iterable<String> collection, final Iterable<?> item, final Service cache) { final String id = uuid(); - final Iterable<?> newItem = list(car(item), id, caddr(item)); + final Iterable<?> newItem = list("'entry", cadr(car(item)), list("'id", id), cadddr(car(item))); final Iterable<?> cart = cons(newItem, this.getcart(cartId, cache)); final Iterable<String> iid = list(cartId); cache.put(iid, cart); @@ -59,9 +59,9 @@ public class ShoppingCartImpl { */ Iterable<?> find(final String id, final Iterable<?> cart) { if(isNil(cart)) - return cons("Item", list("0", list())); - if(id.equals(cadr(car(cart)))) - return car(cart); + return list(list("'entry", list("'title", "Item"), list("'id", "0"))); + if(id.equals(cadr(caddr(car(cart))))) + return list(car(cart)); return this.find(id, cdr(cart)); } @@ -70,7 +70,7 @@ public class ShoppingCartImpl { */ public Iterable<?> get(final Iterable<String> id, final Service cache) { if(isNil(id)) - return cons("Your Cart", cons(cartId, this.getcart(cartId, cache))); + return list(append(list("'feed", list("'title", "Your Cart"), list("'id", cartId)), this.getcart(cartId, cache))); return this.find((String)car(id), this.getcart(cartId, cache)); } @@ -89,7 +89,8 @@ public class ShoppingCartImpl { * Return the price of an item. */ Double price(final Iterable<?> item) { - return Double.valueOf((String)cadr(assoc("'price", caddr(item)))); + System.err.println("price!! " + cadr(cadddr(item))); + return Double.valueOf((String)cadr(assoc("'price", cdr(cadr(cadddr(item)))))); } /** diff --git a/sca-cpp/trunk/samples/store-nosql/htdocs/index.html b/sca-cpp/trunk/samples/store-nosql/htdocs/index.html index 79996c6853..83b1e16df4 100644 --- a/sca-cpp/trunk/samples/store-nosql/htdocs/index.html +++ b/sca-cpp/trunk/samples/store-nosql/htdocs/index.html @@ -24,6 +24,10 @@ <link rel="stylesheet" type="text/css" href="/ui.css"/>
<title>Store</title>
+<script type="text/javascript" src="/util.js"></script>
+<script type="text/javascript" src="/elemutil.js"></script>
+<script type="text/javascript" src="/xmlutil.js"></script>
+<script type="text/javascript" src="/atomutil.js"></script>
<script type="text/javascript" src="/component.js"></script>
<script type="text/javascript">
@@ -50,8 +54,9 @@ function catalog_itemsResponse(items, exception) { }
-function shoppingCart_getResponse(feed) {
- if (feed != null) {
+function shoppingCart_getResponse(doc) {
+ if (doc != null) {
+ var feed = parseXML([doc]);
var entries = feed.getElementsByTagName("entry");
var list = "";
for (var i=0; i<entries.length; i++) {
diff --git a/sca-cpp/trunk/samples/store-nosql/shopping-cart.scm b/sca-cpp/trunk/samples/store-nosql/shopping-cart.scm index 61b169426f..e653f1e33c 100644 --- a/sca-cpp/trunk/samples/store-nosql/shopping-cart.scm +++ b/sca-cpp/trunk/samples/store-nosql/shopping-cart.scm @@ -31,7 +31,7 @@ ; Post a new item to the cart, create a new cart if necessary (define (post collection item cache) (define id (uuid)) - (define newItem (list (car item) id (caddr item))) + (define newItem (list 'entry (cadr (car item)) (list 'id id) (cadddr (car item)))) (define cart (cons newItem (getcart cartId cache))) (cache "put" (list cartId) cart) (list id) @@ -40,16 +40,16 @@ ; Find an item in the cart (define (find id cart) (if (nul cart) - (cons "Item" (list "0" (list))) - (if (= id (cadr (car cart))) - (car cart) + (list (list 'entry (list 'title "Item") (list 'id "0"))) + (if (= id (cadr (caddr (car cart)))) + (list (car cart)) (find id (cdr cart)))) ) ; Get items from the cart (define (get id cache) (if (nul id) - (cons "Your Cart" (cons cartId (getcart cartId cache))) + (list (append (list 'feed (list 'title "Your Cart") (list 'id cartId)) (getcart cartId cache))) (find (car id) (getcart cartId cache)) ) ) @@ -64,7 +64,7 @@ ; Return the price of an item (define (price item) - (cadr (assoc 'price (caddr item))) + (cadr (assoc 'price (cadr (cadddr item)))) ) ; Sum the prices of a list of items diff --git a/sca-cpp/trunk/samples/store-python/htdocs/index.html b/sca-cpp/trunk/samples/store-python/htdocs/index.html index 79996c6853..83b1e16df4 100644 --- a/sca-cpp/trunk/samples/store-python/htdocs/index.html +++ b/sca-cpp/trunk/samples/store-python/htdocs/index.html @@ -24,6 +24,10 @@ <link rel="stylesheet" type="text/css" href="/ui.css"/>
<title>Store</title>
+<script type="text/javascript" src="/util.js"></script>
+<script type="text/javascript" src="/elemutil.js"></script>
+<script type="text/javascript" src="/xmlutil.js"></script>
+<script type="text/javascript" src="/atomutil.js"></script>
<script type="text/javascript" src="/component.js"></script>
<script type="text/javascript">
@@ -50,8 +54,9 @@ function catalog_itemsResponse(items, exception) { }
-function shoppingCart_getResponse(feed) {
- if (feed != null) {
+function shoppingCart_getResponse(doc) {
+ if (doc != null) {
+ var feed = parseXML([doc]);
var entries = feed.getElementsByTagName("entry");
var list = "";
for (var i=0; i<entries.length; i++) {
diff --git a/sca-cpp/trunk/samples/store-python/shopping-cart.py b/sca-cpp/trunk/samples/store-python/shopping-cart.py index feb7398ed9..1dac82522f 100644 --- a/sca-cpp/trunk/samples/store-python/shopping-cart.py +++ b/sca-cpp/trunk/samples/store-python/shopping-cart.py @@ -32,7 +32,7 @@ def getcart(id, cache): # Post a new item to the cart, create a new cart if necessary def post(collection, item, cache): id = str(uuid.uuid1()) - cart = ((item[0], id, item[2]),) + getcart(cartId, cache) + cart = (("'entry", item[0][1], ("'id", id), item[0][3]),) + getcart(cartId, cache) cache.put((cartId,), cart) return (id,) @@ -40,16 +40,16 @@ def post(collection, item, cache): # Find an item in the cart def find(id, cart): if cart == (): - return ("Item", "0", ()) - elif id == cart[0][1]: - return cart[0] + return (("'entry", ("'title", "Item"), ("'id", 0)),) + elif id == cart[0][2][1]: + return (cart[0],) else: return find(id, cart[1:]) # Get items from the cart def get(id, cache): if id == (): - return ("Your Cart", cartId) + getcart(cartId, cache) + return ((("'feed", ("'title", "Your Cart"), ("'id", cartId)) + getcart(cartId, cache)),) return find(id[0], getcart(cartId, cache)) # Delete items from the cart @@ -60,7 +60,7 @@ def delete(id, cache): # Return the price of an item def price(item): - return float(filter(lambda x: x[0] == "'price", item[2])[0][1]) + return float(filter(lambda x: x[0] == "'price", item[3][1][1:])[0][1]) # Sum the prices of a list of items def sum(items): diff --git a/sca-cpp/trunk/samples/store-scheme/htdocs/index.html b/sca-cpp/trunk/samples/store-scheme/htdocs/index.html index 79996c6853..83b1e16df4 100644 --- a/sca-cpp/trunk/samples/store-scheme/htdocs/index.html +++ b/sca-cpp/trunk/samples/store-scheme/htdocs/index.html @@ -24,6 +24,10 @@ <link rel="stylesheet" type="text/css" href="/ui.css"/>
<title>Store</title>
+<script type="text/javascript" src="/util.js"></script>
+<script type="text/javascript" src="/elemutil.js"></script>
+<script type="text/javascript" src="/xmlutil.js"></script>
+<script type="text/javascript" src="/atomutil.js"></script>
<script type="text/javascript" src="/component.js"></script>
<script type="text/javascript">
@@ -50,8 +54,9 @@ function catalog_itemsResponse(items, exception) { }
-function shoppingCart_getResponse(feed) {
- if (feed != null) {
+function shoppingCart_getResponse(doc) {
+ if (doc != null) {
+ var feed = parseXML([doc]);
var entries = feed.getElementsByTagName("entry");
var list = "";
for (var i=0; i<entries.length; i++) {
diff --git a/sca-cpp/trunk/samples/store-scheme/shopping-cart.scm b/sca-cpp/trunk/samples/store-scheme/shopping-cart.scm index 61b169426f..e653f1e33c 100644 --- a/sca-cpp/trunk/samples/store-scheme/shopping-cart.scm +++ b/sca-cpp/trunk/samples/store-scheme/shopping-cart.scm @@ -31,7 +31,7 @@ ; Post a new item to the cart, create a new cart if necessary (define (post collection item cache) (define id (uuid)) - (define newItem (list (car item) id (caddr item))) + (define newItem (list 'entry (cadr (car item)) (list 'id id) (cadddr (car item)))) (define cart (cons newItem (getcart cartId cache))) (cache "put" (list cartId) cart) (list id) @@ -40,16 +40,16 @@ ; Find an item in the cart (define (find id cart) (if (nul cart) - (cons "Item" (list "0" (list))) - (if (= id (cadr (car cart))) - (car cart) + (list (list 'entry (list 'title "Item") (list 'id "0"))) + (if (= id (cadr (caddr (car cart)))) + (list (car cart)) (find id (cdr cart)))) ) ; Get items from the cart (define (get id cache) (if (nul id) - (cons "Your Cart" (cons cartId (getcart cartId cache))) + (list (append (list 'feed (list 'title "Your Cart") (list 'id cartId)) (getcart cartId cache))) (find (car id) (getcart cartId cache)) ) ) @@ -64,7 +64,7 @@ ; Return the price of an item (define (price item) - (cadr (assoc 'price (caddr item))) + (cadr (assoc 'price (cadr (cadddr item)))) ) ; Sum the prices of a list of items diff --git a/sca-cpp/trunk/samples/store-sql/htdocs/index.html b/sca-cpp/trunk/samples/store-sql/htdocs/index.html index 79996c6853..83b1e16df4 100644 --- a/sca-cpp/trunk/samples/store-sql/htdocs/index.html +++ b/sca-cpp/trunk/samples/store-sql/htdocs/index.html @@ -24,6 +24,10 @@ <link rel="stylesheet" type="text/css" href="/ui.css"/>
<title>Store</title>
+<script type="text/javascript" src="/util.js"></script>
+<script type="text/javascript" src="/elemutil.js"></script>
+<script type="text/javascript" src="/xmlutil.js"></script>
+<script type="text/javascript" src="/atomutil.js"></script>
<script type="text/javascript" src="/component.js"></script>
<script type="text/javascript">
@@ -50,8 +54,9 @@ function catalog_itemsResponse(items, exception) { }
-function shoppingCart_getResponse(feed) {
- if (feed != null) {
+function shoppingCart_getResponse(doc) {
+ if (doc != null) {
+ var feed = parseXML([doc]);
var entries = feed.getElementsByTagName("entry");
var list = "";
for (var i=0; i<entries.length; i++) {
diff --git a/sca-cpp/trunk/samples/store-sql/shopping-cart.scm b/sca-cpp/trunk/samples/store-sql/shopping-cart.scm index 61b169426f..e653f1e33c 100644 --- a/sca-cpp/trunk/samples/store-sql/shopping-cart.scm +++ b/sca-cpp/trunk/samples/store-sql/shopping-cart.scm @@ -31,7 +31,7 @@ ; Post a new item to the cart, create a new cart if necessary (define (post collection item cache) (define id (uuid)) - (define newItem (list (car item) id (caddr item))) + (define newItem (list 'entry (cadr (car item)) (list 'id id) (cadddr (car item)))) (define cart (cons newItem (getcart cartId cache))) (cache "put" (list cartId) cart) (list id) @@ -40,16 +40,16 @@ ; Find an item in the cart (define (find id cart) (if (nul cart) - (cons "Item" (list "0" (list))) - (if (= id (cadr (car cart))) - (car cart) + (list (list 'entry (list 'title "Item") (list 'id "0"))) + (if (= id (cadr (caddr (car cart)))) + (list (car cart)) (find id (cdr cart)))) ) ; Get items from the cart (define (get id cache) (if (nul id) - (cons "Your Cart" (cons cartId (getcart cartId cache))) + (list (append (list 'feed (list 'title "Your Cart") (list 'id cartId)) (getcart cartId cache))) (find (car id) (getcart cartId cache)) ) ) @@ -64,7 +64,7 @@ ; Return the price of an item (define (price item) - (cadr (assoc 'price (caddr item))) + (cadr (assoc 'price (cadr (cadddr item)))) ) ; Sum the prices of a list of items diff --git a/sca-cpp/trunk/samples/store-vhost/domains/jane/htdocs/index.html b/sca-cpp/trunk/samples/store-vhost/domains/jane/htdocs/index.html index 4cd219bc9c..09e2c4ab83 100644 --- a/sca-cpp/trunk/samples/store-vhost/domains/jane/htdocs/index.html +++ b/sca-cpp/trunk/samples/store-vhost/domains/jane/htdocs/index.html @@ -22,8 +22,12 @@ <meta name="apple-mobile-web-app-capable" content="yes"/>
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent"/>
<link rel="stylesheet" type="text/css" href="/ui.css"/>
-<title>Store</title>
+<title>Jane's Store</title>
+<script type="text/javascript" src="/util.js"></script>
+<script type="text/javascript" src="/elemutil.js"></script>
+<script type="text/javascript" src="/xmlutil.js"></script>
+<script type="text/javascript" src="/atomutil.js"></script>
<script type="text/javascript" src="/component.js"></script>
<script type="text/javascript">
@@ -50,8 +54,9 @@ function catalog_itemsResponse(items, exception) { }
-function shoppingCart_getResponse(feed) {
- if (feed != null) {
+function shoppingCart_getResponse(doc) {
+ if (doc != null) {
+ var feed = parseXML([doc]);
var entries = feed.getElementsByTagName("entry");
var list = "";
for (var i=0; i<entries.length; i++) {
diff --git a/sca-cpp/trunk/samples/store-vhost/domains/jane/shopping-cart.py b/sca-cpp/trunk/samples/store-vhost/domains/jane/shopping-cart.py index feb7398ed9..1dac82522f 100644 --- a/sca-cpp/trunk/samples/store-vhost/domains/jane/shopping-cart.py +++ b/sca-cpp/trunk/samples/store-vhost/domains/jane/shopping-cart.py @@ -32,7 +32,7 @@ def getcart(id, cache): # Post a new item to the cart, create a new cart if necessary def post(collection, item, cache): id = str(uuid.uuid1()) - cart = ((item[0], id, item[2]),) + getcart(cartId, cache) + cart = (("'entry", item[0][1], ("'id", id), item[0][3]),) + getcart(cartId, cache) cache.put((cartId,), cart) return (id,) @@ -40,16 +40,16 @@ def post(collection, item, cache): # Find an item in the cart def find(id, cart): if cart == (): - return ("Item", "0", ()) - elif id == cart[0][1]: - return cart[0] + return (("'entry", ("'title", "Item"), ("'id", 0)),) + elif id == cart[0][2][1]: + return (cart[0],) else: return find(id, cart[1:]) # Get items from the cart def get(id, cache): if id == (): - return ("Your Cart", cartId) + getcart(cartId, cache) + return ((("'feed", ("'title", "Your Cart"), ("'id", cartId)) + getcart(cartId, cache)),) return find(id[0], getcart(cartId, cache)) # Delete items from the cart @@ -60,7 +60,7 @@ def delete(id, cache): # Return the price of an item def price(item): - return float(filter(lambda x: x[0] == "'price", item[2])[0][1]) + return float(filter(lambda x: x[0] == "'price", item[3][1][1:])[0][1]) # Sum the prices of a list of items def sum(items): diff --git a/sca-cpp/trunk/samples/store-vhost/domains/joe/htdocs/index.html b/sca-cpp/trunk/samples/store-vhost/domains/joe/htdocs/index.html index c32dcd9d53..4a25ff4afa 100644 --- a/sca-cpp/trunk/samples/store-vhost/domains/joe/htdocs/index.html +++ b/sca-cpp/trunk/samples/store-vhost/domains/joe/htdocs/index.html @@ -22,8 +22,12 @@ <meta name="apple-mobile-web-app-capable" content="yes"/>
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent"/>
<link rel="stylesheet" type="text/css" href="/ui.css"/>
-<title>Store</title>
+<title>Joe's Store</title>
+<script type="text/javascript" src="/util.js"></script>
+<script type="text/javascript" src="/elemutil.js"></script>
+<script type="text/javascript" src="/xmlutil.js"></script>
+<script type="text/javascript" src="/atomutil.js"></script>
<script type="text/javascript" src="/component.js"></script>
<script type="text/javascript">
@@ -50,8 +54,9 @@ function catalog_itemsResponse(items, exception) { }
-function shoppingCart_getResponse(feed) {
- if (feed != null) {
+function shoppingCart_getResponse(doc) {
+ if (doc != null) {
+ var feed = parseXML([doc]);
var entries = feed.getElementsByTagName("entry");
var list = "";
for (var i=0; i<entries.length; i++) {
diff --git a/sca-cpp/trunk/samples/store-vhost/domains/joe/shopping-cart.py b/sca-cpp/trunk/samples/store-vhost/domains/joe/shopping-cart.py index feb7398ed9..1dac82522f 100644 --- a/sca-cpp/trunk/samples/store-vhost/domains/joe/shopping-cart.py +++ b/sca-cpp/trunk/samples/store-vhost/domains/joe/shopping-cart.py @@ -32,7 +32,7 @@ def getcart(id, cache): # Post a new item to the cart, create a new cart if necessary def post(collection, item, cache): id = str(uuid.uuid1()) - cart = ((item[0], id, item[2]),) + getcart(cartId, cache) + cart = (("'entry", item[0][1], ("'id", id), item[0][3]),) + getcart(cartId, cache) cache.put((cartId,), cart) return (id,) @@ -40,16 +40,16 @@ def post(collection, item, cache): # Find an item in the cart def find(id, cart): if cart == (): - return ("Item", "0", ()) - elif id == cart[0][1]: - return cart[0] + return (("'entry", ("'title", "Item"), ("'id", 0)),) + elif id == cart[0][2][1]: + return (cart[0],) else: return find(id, cart[1:]) # Get items from the cart def get(id, cache): if id == (): - return ("Your Cart", cartId) + getcart(cartId, cache) + return ((("'feed", ("'title", "Your Cart"), ("'id", cartId)) + getcart(cartId, cache)),) return find(id[0], getcart(cartId, cache)) # Delete items from the cart @@ -60,7 +60,7 @@ def delete(id, cache): # Return the price of an item def price(item): - return float(filter(lambda x: x[0] == "'price", item[2])[0][1]) + return float(filter(lambda x: x[0] == "'price", item[3][1][1:])[0][1]) # Sum the prices of a list of items def sum(items): |