You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by js...@apache.org on 2011/03/08 09:18:09 UTC

svn commit: r1079292 [2/2] - in /tuscany/sca-cpp/trunk: components/cache/ components/chat/ components/filedb/ components/log/ components/nosqldb/ components/queue/ components/sqldb/ kernel/ modules/atom/ modules/edit/ modules/edit/apps/me360/ modules/e...

Modified: tuscany/sca-cpp/trunk/modules/rss/rss-test.cpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/modules/rss/rss-test.cpp?rev=1079292&r1=1079291&r2=1079292&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/modules/rss/rss-test.cpp (original)
+++ tuscany/sca-cpp/trunk/modules/rss/rss-test.cpp Tue Mar  8 08:18:07 2011
@@ -88,19 +88,27 @@ bool testEntry() {
         const list<value> i = list<value>() + element + value("item")
                 + value(list<value>() + element + value("name") + value(string("Apple")))
                 + value(list<value>() + element + value("price") + value(string("$2.99")));
-        const list<value> a = mklist<value>(string("fruit"), string("cart-53d67a61-aa5e-4e5e-8401-39edeba8b83b"), i);
+        const list<value> a = list<value>() + (list<value>() + element + value("entry")
+                + value(list<value>() + element + value("title") + value(string("fruit")))
+                + value(list<value>() + element + value("id") + value(string("cart-53d67a61-aa5e-4e5e-8401-39edeba8b83b")))
+                + value(list<value>() + element + value("content") + value(i)));
         ostringstream os;
         writeRSSEntry<ostream*>(writer, &os, a);
         assert(str(os) == itemEntry);
     }
     {
-        const list<value> a = mklist<value>(string("fruit"), string("cart-53d67a61-aa5e-4e5e-8401-39edeba8b83b"), "Apple");
+        const list<value> a = list<value>() + (list<value>() + element + value("entry")
+                + value(list<value>() + element + value("title") + value(string("fruit")))
+                + value(list<value>() + element + value("id") + value(string("cart-53d67a61-aa5e-4e5e-8401-39edeba8b83b")))
+                + value(list<value>() + element + value("content") + value(string("Apple"))));
         ostringstream os;
         writeRSSEntry<ostream*>(writer, &os, a);
         assert(str(os) == itemTextEntry);
     }
     {
-        const list<value> a = mklist<value>(string("fruit"), string("cart-53d67a61-aa5e-4e5e-8401-39edeba8b83b"), list<value>());
+        const list<value> a = list<value>() + (list<value>() + element + value("entry")
+                + value(list<value>() + element + value("title") + value(string("fruit")))
+                + value(list<value>() + element + value("id") + value(string("cart-53d67a61-aa5e-4e5e-8401-39edeba8b83b"))));
         ostringstream os;
         writeRSSEntry<ostream*>(writer, &os, a);
         assert(str(os) == itemNoDescriptionEntry);
@@ -172,8 +180,11 @@ const string itemFeed("<?xml version=\"1
 
 bool testFeed() {
     {
+        const list<value> a = list<value>() + (list<value>() + element + value("feed")
+                + value(list<value>() + element + value("title") + value(string("Feed")))
+                + value(list<value>() + element + value("id") + value(string("1234"))));
         ostringstream os;
-        writeRSSFeed<ostream*>(writer, &os, mklist<value>("Feed", "1234"));
+        writeRSSFeed<ostream*>(writer, &os, a);
         assert(str(os) == emptyFeed);
     }
     {
@@ -183,39 +194,43 @@ bool testFeed() {
         assert(str(os) == emptyFeed);
     }
     {
-        const list<value> i = list<value>()
-                + (list<value>() + "fruit" + "cart-53d67a61-aa5e-4e5e-8401-39edeba8b83b"
-                    + (list<value>() + element + "item"
+        const list<value> i1 = list<value>() + element + "item"
                         + (list<value>() + element + "name" + "Apple")
-                        + (list<value>() + element + "price" + "$2.99")))
-                + (list<value>() + "fruit" + "cart-53d67a61-aa5e-4e5e-8401-39edeba8b83c"
-                    + (list<value>() + element + "item"
+                        + (list<value>() + element + "price" + "$2.99");
+
+        const list<value> i2 = list<value>() + element + "item"
                         + (list<value>() + element + "name" + "Orange")
-                        + (list<value>() + element + "price" + "$3.55")));
-        const list<value> a = cons<value>("Feed", cons<value>("1234", i));
+                        + (list<value>() + element + "price" + "$3.55");
+
+        const list<value> i = list<value>()
+            + value(list<value>() + element + value("entry")
+                + value(list<value>() + element + value("title") + value(string("fruit")))
+                + value(list<value>() + element + value("id") + value(string("cart-53d67a61-aa5e-4e5e-8401-39edeba8b83b")))
+                + value(list<value>() + element + value("content") + value(i1)))
+            + value(list<value>() + element + value("entry")
+                + value(list<value>() + element + value("title") + value(string("fruit")))
+                + value(list<value>() + element + value("id") + value(string("cart-53d67a61-aa5e-4e5e-8401-39edeba8b83c")))
+                + value(list<value>() + element + value("content") + value(i2)));
+        
+        const list<value> a = list<value>() + (append<value>(list<value>() + element + value("feed")
+                + value(list<value>() + element + value("title") + value(string("Feed")))
+                + value(list<value>() + element + value("id") + value("1234")),
+                i));
+
         ostringstream os;
         writeRSSFeed<ostream*>(writer, &os, a);
         assert(str(os) == itemFeed);
     }
     {
-        const list<value> i = list<value>()
-                + (list<value>() + "fruit" + "cart-53d67a61-aa5e-4e5e-8401-39edeba8b83b"
-                    + valueToElement(list<value>() + "item"
-                        + (list<value>() + "name" + "Apple")
-                        + (list<value>() + "price" + "$2.99")))
-                + (list<value>() + "fruit" + "cart-53d67a61-aa5e-4e5e-8401-39edeba8b83c"
-                    + valueToElement(list<value>() + "item"
-                        + (list<value>() + "name" + "Orange")
-                        + (list<value>() + "price" + "$3.55")));
-        const list<value> a = cons<value>("Feed", cons<value>("1234", i));
+        const list<value> a = content(readRSSFeed(mklist(itemFeed)));
         ostringstream os;
         writeRSSFeed<ostream*>(writer, &os, a);
         assert(str(os) == itemFeed);
     }
     {
-        const list<value> a = content(readRSSFeed(mklist(itemFeed)));
+        const list<value> a = elementsToValues(content(readRSSFeed(mklist(itemFeed))));
         ostringstream os;
-        writeRSSFeed<ostream*>(writer, &os, a);
+        writeRSSFeed<ostream*>(writer, &os, valuesToElements(a));
         assert(str(os) == itemFeed);
     }
     return true;

Modified: tuscany/sca-cpp/trunk/modules/rss/rss.hpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/modules/rss/rss.hpp?rev=1079292&r1=1079291&r2=1079292&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/modules/rss/rss.hpp (original)
+++ tuscany/sca-cpp/trunk/modules/rss/rss.hpp Tue Mar  8 08:18:07 2011
@@ -36,24 +36,33 @@ namespace tuscany {
 namespace rss {
 
 /**
- * Convert a list of elements to a list of values representing an RSS entry.
+ * Tags used to tag feed and entry elements.
  */
-const list<value> entryElementsToValues(const list<value>& e) {
+const value feed("feed");
+const value entry("entry");
+
+/**
+ * Convert a list of elements to a list of element values representing an RSS entry.
+ */
+const list<value> entryElementValues(const list<value>& e) {
     const list<value> lt = filter<value>(selector(mklist<value>(element, "title")), e);
     const value t = isNil(lt)? value(emptyString) : elementValue(car(lt));
     const list<value> li = filter<value>(selector(mklist<value>(element, "link")), e);
     const value i = isNil(li)? value(emptyString) : elementValue(car(li));
     const list<value> ld = filter<value>(selector(mklist<value>(element, "description")), e);
-    return mklist<value>(t, i, isNil(ld)? (value)list<value>() : elementValue(car(ld)));
+    return append<value>(list<value>() + element + entry 
+                + value(list<value>() + element + value("title") + t)
+                + value(list<value>() + element + value("id") + i),
+                isNil(ld)? list<value>() : mklist<value>(value(list<value>() + element + value("content") + elementValue(car(ld)))));
 }
 
 /**
- * Convert a list of elements to a list of values representing RSS entries.
+ * Convert a list of elements to a list of element values representing ATOM entries.
  */
-const list<value> entriesElementsToValues(const list<value>& e) {
+const list<value> entriesElementValues(const list<value>& e) {
     if (isNil(e))
         return e;
-    return cons<value>(entryElementsToValues(car(e)), entriesElementsToValues(cdr(e)));
+    return cons<value>(entryElementValues(car(e)), entriesElementValues(cdr(e)));
 }
 
 /**
@@ -72,15 +81,7 @@ const failable<list<value> > readRSSEntr
     const list<value> e = readXML(ilist);
     if (isNil(e))
         return mkfailure<list<value> >("Empty entry");
-    return entryElementsToValues(car(e));
-}
-
-/**
- * Convert a list of values representing an RSS entry to a value.
- */
-const value entryValue(const list<value>& e) {
-    const list<value> v = elementsToValues(mklist<value>(caddr(e)));
-    return cons(car(e), mklist<value>(cadr(e), isList(car(v))? (isNil((list<value>)car(v))? car(v) : (value)cdr<value>(car(v))) : car(v)));
+    return mklist<value>(entryElementValues(car(e)));
 }
 
 /**
@@ -94,34 +95,28 @@ const failable<list<value> > readRSSFeed
     const list<value> t = filter<value>(selector(mklist<value>(element, "title")), car(c));
     const list<value> i = filter<value>(selector(mklist<value>(element, "link")), car(c));
     const list<value> e = filter<value>(selector(mklist<value>(element, "item")), car(c));
-    if (isNil(e))
-        return mklist<value>(elementValue(car(t)), elementValue(car(i)));
-    return cons<value>(elementValue(car(t)), cons(elementValue(car(i)), entriesElementsToValues(e)));
+    return mklist<value>(append<value>(list<value>() + element + feed 
+                + value(list<value>() + element + value("title") + elementValue(car(t)))
+                + value(list<value>() + element + value("id") + elementValue(car(i))),
+                entriesElementValues(e)));
 }
 
 /**
- * Convert an RSS feed containing elements to an RSS feed containing values.
- */
-const list<value> feedValuesLoop(const list<value> e) {
-    if (isNil(e))
-        return e;
-    return cons<value>(entryValue(car(e)), feedValuesLoop(cdr(e)));
-}
-
-const list<value> feedValues(const list<value>& e) {
-    return cons(car<value>(e), cons<value>(cadr<value>(e), feedValuesLoop(cddr<value>(e))));
-}
-
-/**
- * Convert a list of values representing an RSS entry to a list of elements.
- * The first two values in the list are the entry title and id.
+ * Convert a list of element values representing an RSS entry to a list of elements.
  */
 const list<value> entryElement(const list<value>& l) {
-    return list<value>()
+    const value title = elementValue(elementChild("title", l));
+    const value id = elementValue(elementChild("id", l));
+    const value content = elementChild("content", l);
+    const bool text = isNil(content)? false : elementHasValue(content);
+    return append<value>(list<value>()
         + element + "item"
-        + (list<value>() + element + "title" + car(l))
-        + (list<value>() + element + "link" + cadr(l))
-        + (isNil(cddr(l))? list<value>() : list<value>() + element + "description" + caddr(l));
+        + (list<value>() + element + "title" + title)
+        + (list<value>() + element + "link" + id),
+        isNil(content)?
+            list<value>() :
+            mklist<value>(append<value>(list<value>() + element + "description",
+                text? mklist<value>(elementValue(content)) : elementChildren(content))));
 }
 
 /**
@@ -137,7 +132,8 @@ const list<value> entriesElements(const 
  * Convert a list of values representing an RSS entry to an RSS entry.
  * The first two values in the list are the entry id and title.
  */
-template<typename R> const failable<R> writeRSSEntry(const lambda<R(const string&, const R)>& reduce, const R& initial, const list<value>& l) {
+template<typename R> const failable<R> writeRSSEntry(const lambda<R(const string&, const R)>& reduce, const R& initial, const list<value>& ll) {
+    const list<value> l = isNil(ll)? ll : (list<value>)car(ll);
     return writeXML<R>(reduce, initial, mklist<value>(entryElement(l)));
 }
 
@@ -152,12 +148,37 @@ const failable<list<string> > writeRSSEn
  * Convert a list of values representing an RSS feed to an RSS feed.
  * The first two values in the list are the feed id and title.
  */
-template<typename R> const failable<R> writeRSSFeed(const lambda<R(const string&, const R)>& reduce, const R& initial, const list<value>& l) {
+template<typename R> const failable<R> writeRSSFeed(const lambda<R(const string&, const R)>& reduce, const R& initial, const list<value>& ll) {
+    const list<value> l = isNil(ll)? ll : (list<value>)car(ll);
+    const list<value> lt = filter<value>(selector(mklist<value>(element, "title")), l);
+    const value t = isNil(lt)? value(emptyString) : elementValue(car(lt));
+    const list<value> li = filter<value>(selector(mklist<value>(element, "id")), l);
+    const value i = isNil(li)? value(emptyString) : elementValue(car(li));
     const list<value> c = list<value>()
-        + (list<value>() + element + "title" + car(l))
-        + (list<value>() + element + "link" + cadr(l))
-        + (list<value>() + element + "description" + car(l));
-    const list<value> ce = isNil(cddr(l))? c : append(c, entriesElements(cddr(l)));
+        + (list<value>() + element + "title" + t)
+        + (list<value>() + element + "link" + i)
+        + (list<value>() + element + "description" + t);
+
+    // Write RSS entries
+    const list<value> le = filter<value>(selector(mklist<value>(element, entry)), l);
+    if (isNil(le)) {
+        const list<value> fe = list<value>()
+            + element + "rss" + (list<value>() + attribute + "version" + "2.0")
+            + append(list<value>() + element + "channel", c);
+        return writeXML<R>(reduce, initial, mklist<value>(fe));
+    }
+
+    // Write a single RSS entry element with a list of values
+    if (!isNil(le) && !isNil(car(le)) && isList(car<value>(caddr<value>(car(le))))) {
+        const list<value> ce = append(c, entriesElements(caddr<value>(car(le))));
+        const list<value> fe = list<value>()
+            + element + "rss" + (list<value>() + attribute + "version" + "2.0")
+            + append(list<value>() + element + "channel", ce);
+        return writeXML<R>(reduce, initial, mklist<value>(fe));
+    }
+
+    // Write separate RSS entry elements
+    const list<value> ce = append(c, entriesElements(le));
     const list<value> fe = list<value>()
         + element + "rss" + (list<value>() + attribute + "version" + "2.0")
         + append(list<value>() + element + "channel", ce);
@@ -175,26 +196,6 @@ const failable<list<string> > writeRSSFe
     return reverse(list<string>(content(ls)));
 }
 
-/**
- * Convert an RSS entry containing a value to an RSS entry containing an item element.
- */
-const list<value> entryValuesToElements(const list<value> val) {
-    return cons(car(val), cons(cadr(val), valuesToElements(mklist<value>(cons<value>("item", (list<value>)caddr(val))))));
-}
-
-/**
- * Convert an RSS feed containing values to an RSS feed containing elements.
- */
-const list<value> feedValuesToElementsLoop(const list<value> val) {
-    if (isNil(val))
-        return val;
-    return cons<value>(entryValuesToElements(car(val)), feedValuesToElementsLoop(cdr(val)));
-}
-
-const list<value> feedValuesToElements(const list<value>& val) {
-    return cons(car<value>(val), cons<value>(cadr<value>(val), feedValuesToElementsLoop(cddr<value>(val))));
-}
-
 }
 }
 

Modified: tuscany/sca-cpp/trunk/modules/scheme/json-value.cpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/modules/scheme/json-value.cpp?rev=1079292&r1=1079291&r2=1079292&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/modules/scheme/json-value.cpp (original)
+++ tuscany/sca-cpp/trunk/modules/scheme/json-value.cpp Tue Mar  8 08:18:07 2011
@@ -39,8 +39,7 @@ int jsonValue() {
         cerr << reason(lv);
         return 1;
     }
-    const value v = elementsToValues(content(lv));
-    cout << writeValue(v);
+    cout << writeValue(content(lv));
     return 0;
 }
 

Modified: tuscany/sca-cpp/trunk/modules/scheme/primitive.hpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/modules/scheme/primitive.hpp?rev=1079292&r1=1079291&r2=1079292&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/modules/scheme/primitive.hpp (original)
+++ tuscany/sca-cpp/trunk/modules/scheme/primitive.hpp Tue Mar  8 08:18:07 2011
@@ -145,26 +145,30 @@ const value uuidProc(unused const list<v
     return mkuuid();
 }
 
-const value cadrProc(unused const list<value>& args) {
+const value cadrProc(const list<value>& args) {
     return cadr((list<value> )car(args));
 }
 
-const value caddrProc(unused const list<value>& args) {
+const value caddrProc(const list<value>& args) {
     return caddr((list<value> )car(args));
 }
 
-const value cadddrProc(unused const list<value>& args) {
+const value cadddrProc(const list<value>& args) {
     return cadddr((list<value> )car(args));
 }
 
-const value cddrProc(unused const list<value>& args) {
+const value cddrProc(const list<value>& args) {
     return cddr((list<value> )car(args));
 }
 
-const value cdddrProc(unused const list<value>& args) {
+const value cdddrProc(const list<value>& args) {
     return cdddr((list<value> )car(args));
 }
 
+const value appendProc(const list<value>& args) {
+    return append((list<value> )car(args), (list<value>)cadr(args));
+}
+
 const value startProc(unused const list<value>& args) {
     return lambda<value(const list<value>&)>();
 }
@@ -222,6 +226,7 @@ const list<value> primitiveProcedureName
     + "cadddr"
     + "cddr"
     + "cdddr"
+    + "append"
     + "display"
     + "log"
     + "uuid"
@@ -247,6 +252,7 @@ const list<value> primitiveProcedureObje
     + primitiveProcedure(cadddrProc)
     + primitiveProcedure(cddrProc)
     + primitiveProcedure(cdddrProc)
+    + primitiveProcedure(appendProc)
     + primitiveProcedure(displayProc)
     + primitiveProcedure(logProc)
     + primitiveProcedure(uuidProc)

Modified: tuscany/sca-cpp/trunk/modules/scheme/value-json.cpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/modules/scheme/value-json.cpp?rev=1079292&r1=1079291&r2=1079292&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/modules/scheme/value-json.cpp (original)
+++ tuscany/sca-cpp/trunk/modules/scheme/value-json.cpp Tue Mar  8 08:18:07 2011
@@ -34,7 +34,7 @@ namespace scheme {
 
 int valueJSON() {
     const js::JSContext cx;
-    failable<list<string> > s = json::writeJSON(valuesToElements(readValue(cin)), cx);
+    failable<list<string> > s = json::writeJSON(readValue(cin), cx);
     if (!hasContent(s)) {
         cerr << reason(s);
         return 1;

Modified: tuscany/sca-cpp/trunk/modules/scheme/value-xml.cpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/modules/scheme/value-xml.cpp?rev=1079292&r1=1079291&r2=1079292&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/modules/scheme/value-xml.cpp (original)
+++ tuscany/sca-cpp/trunk/modules/scheme/value-xml.cpp Tue Mar  8 08:18:07 2011
@@ -33,7 +33,7 @@ namespace tuscany {
 namespace scheme {
 
 int valueXML() {
-    failable<list<string> > s = writeXML(valuesToElements(readValue(cin)));
+    failable<list<string> > s = writeXML(readValue(cin));
     if (!hasContent(s)) {
         cerr << reason(s);
         return 1;

Modified: tuscany/sca-cpp/trunk/modules/scheme/xml-value.cpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/modules/scheme/xml-value.cpp?rev=1079292&r1=1079291&r2=1079292&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/modules/scheme/xml-value.cpp (original)
+++ tuscany/sca-cpp/trunk/modules/scheme/xml-value.cpp Tue Mar  8 08:18:07 2011
@@ -33,7 +33,7 @@ namespace tuscany {
 namespace scheme {
 
 int xmlValue() {
-    const value v = elementsToValues(readXML(streamList(cin)));
+    const value v = readXML(streamList(cin));
     cout << writeValue(v);
     return 0;
 }

Modified: tuscany/sca-cpp/trunk/modules/server/client-test.hpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/modules/server/client-test.hpp?rev=1079292&r1=1079291&r2=1079292&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/modules/server/client-test.hpp (original)
+++ tuscany/sca-cpp/trunk/modules/server/client-test.hpp Tue Mar  8 08:18:07 2011
@@ -132,10 +132,13 @@ const bool testEvalPerf() {
 
 bool testPost() {
     gc_scoped_pool pool;
-    const list<value> i = list<value>()
+    const list<value> i = list<value>() + "content" + (list<value>() + "item"
             + (list<value>() + "name" + string("Apple"))
-            + (list<value>() + "price" + string("$2.99"));
-    const list<value> a = mklist<value>(string("item"), string("cart-53d67a61-aa5e-4e5e-8401-39edeba8b83b"), i);
+            + (list<value>() + "price" + string("$2.99")));
+    const list<value> a = list<value>() + (list<value>() + "entry" 
+            + (list<value>() + "title" + string("item"))
+            + (list<value>() + "id" + string("cart-53d67a61-aa5e-4e5e-8401-39edeba8b83b"))
+            + i);
     http::CURLSession ch("", "", "");
     const failable<value> id = http::post(a, testURI, ch);
     assert(hasContent(id));
@@ -173,20 +176,26 @@ const bool testPostPerf() {
     gc_scoped_pool pool;
     http::CURLSession ch("", "", "");
     {
-        const list<value> i = list<value>()
+        const list<value> i = list<value>() + "content" + (list<value>() + "item" 
             + (list<value>() + "name" + string("Apple"))
-            + (list<value>() + "price" + string("$2.99"));
-        const list<value> val = mklist<value>(string("item"), string("cart-53d67a61-aa5e-4e5e-8401-39edeba8b83b"), i);
+            + (list<value>() + "price" + string("$2.99")));
+        const list<value> val = list<value>() + (list<value>() + "entry" 
+            + (list<value>() + "title" + string("item"))
+            + (list<value>() + "id" + string("cart-53d67a61-aa5e-4e5e-8401-39edeba8b83b"))
+            + i);
         const lambda<bool()> pl = postLoop(testURI, val, ch);
         cout << "ATOMPub POST small test " << time(pl, 5, 200) << " ms" << endl;
     }
     if (testBlobs) {
-        const list<value> i = list<value>()
+        const list<value> i = list<value>() + "content" + (list<value>() + "item"
             + (list<value>() + "name" + string("Apple"))
             + (list<value>() + "blob1" + blob)
             + (list<value>() + "blob2" + blob)
-            + (list<value>() + "price" + string("$2.99"));
-        const list<value> val = mklist<value>(string("item"), string("cart-53d67a61-aa5e-4e5e-8401-39edeba8b83b"), i);
+            + (list<value>() + "price" + string("$2.99")));
+        const list<value> val = list<value>() + (list<value>() + "entry" 
+            + (list<value>() + "title" + string("item"))
+            + (list<value>() + "id" + string("cart-53d67a61-aa5e-4e5e-8401-39edeba8b83b"))
+            + i);
         const lambda<bool()> pl = postBlobLoop(testURI, val, ch);
         cout << "ATOMPub POST blob test  " << time(pl, 5, 200) << " ms" << endl;
     }
@@ -234,10 +243,13 @@ const bool testPostThreadPerf() {
     const int count = 50;
     const int threads = 10;
 
-    const list<value> i = list<value>()
-        + (list<value>() + "name" + string("Apple"))
-        + (list<value>() + "price" + string("$2.99"));
-    const value val = mklist<value>(string("item"), string("cart-53d67a61-aa5e-4e5e-8401-39edeba8b83b"), i);
+    const list<value> i = list<value>() + "content" + (list<value>() + "item"
+            + (list<value>() + "name" + string("Apple"))
+            + (list<value>() + "price" + string("$2.99")));
+    const value val = list<value>() + (list<value>() + "entry" 
+            + (list<value>() + "title" + string("item"))
+            + (list<value>() + "id" + string("cart-53d67a61-aa5e-4e5e-8401-39edeba8b83b"))
+            + i);
 
     const lambda<bool()> pl= curry(lambda<bool(const string, const int, const value)>(postThread), testURI, count, val);
     const lambda<bool()> ptl = postThreadLoop(pl, threads);
@@ -294,10 +306,13 @@ const bool testPostForkPerf() {
     const int count = 50;
     const int procs = 10;
 
-    const list<value> i = list<value>()
-        + (list<value>() + "name" + string("Apple"))
-        + (list<value>() + "price" + string("$2.99"));
-    const value val = mklist<value>(string("item"), string("cart-53d67a61-aa5e-4e5e-8401-39edeba8b83b"), i);
+    const list<value> i = list<value>() + "content" + (list<value>() + "item"
+            + (list<value>() + "name" + string("Apple"))
+            + (list<value>() + "price" + string("$2.99")));
+    const list<value> val = list<value>() + (list<value>() + "entry" 
+            + (list<value>() + "title" + string("item"))
+            + (list<value>() + "id" + string("cart-53d67a61-aa5e-4e5e-8401-39edeba8b83b"))
+            + i);
 
     const lambda<bool()> pl= curry(lambda<bool(const string, const int, const value)>(postProc), testURI, count, val);
     const lambda<bool()> ptl = postForkLoop(pl, procs);
@@ -311,10 +326,13 @@ const bool testPostForkPerf() {
 
 const bool testPut() {
     gc_scoped_pool pool;
-    const list<value> i = list<value>()
+    const list<value> i = list<value>() + "content" + (list<value>() + "item"
             + (list<value>() + "name" + string("Apple"))
-            + (list<value>() + "price" + string("$2.99"));
-    const list<value> a = mklist<value>(string("item"), string("cart-53d67a61-aa5e-4e5e-8401-39edeba8b83b"), i);
+            + (list<value>() + "price" + string("$2.99")));
+    const list<value> a = list<value>() + (list<value>() + "entry" 
+            + (list<value>() + "title" + string("item"))
+            + (list<value>() + "id" + string("cart-53d67a61-aa5e-4e5e-8401-39edeba8b83b"))
+            + i);
     http::CURLSession ch("", "", "");
     value rc = content(http::put(a, testURI + "/111", ch));
     assert(rc == value(true));

Modified: tuscany/sca-cpp/trunk/modules/server/mod-eval.hpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/modules/server/mod-eval.hpp?rev=1079292&r1=1079291&r2=1079292&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/modules/server/mod-eval.hpp (original)
+++ tuscany/sca-cpp/trunk/modules/server/mod-eval.hpp Tue Mar  8 08:18:07 2011
@@ -143,27 +143,34 @@ const failable<int> get(request_rec* r, 
         return httpd::writeResult(json::writeJSON(list<value>(), cx), "application/json", r);
     }
 
+    // Write content-type / content-list pair
+    if (isString(car<value>(c)) && !isNil(cdr<value>(c)) && isList(cadr<value>(c)))
+        return httpd::writeResult(convertValues<string>(cadr<value>(c)), car<value>(c), r);
+
     // Write an assoc value as a JSON result
     if (isSymbol(car<value>(c)) && !isNil(cdr<value>(c))) {
         js::JSContext cx;
         return httpd::writeResult(json::writeJSON(valuesToElements(mklist<value>(c)), cx), "application/json", r);
     }
 
-    // Write content-type / content-list pair
-    if (isString(car<value>(c)) && !isNil(cdr<value>(c)) && isList(cadr<value>(c)))
-        return httpd::writeResult(convertValues<string>(cadr<value>(c)), car<value>(c), r);
+    // Convert list of values to element values
+    const list<value> e = valuesToElements(c);
+    debug(e, "modeval::get::elements");
 
     // Write an ATOM feed or entry
-    if (isString(car<value>(c)) && !isNil(cdr<value>(c)) && isString(cadr<value>(c))) {
-        if (isNil(cddr(path)))
-            return httpd::writeResult(atom::writeATOMFeed(atom::feedValuesToElements(c)), "application/atom+xml", r);
-        else
-            return httpd::writeResult(atom::writeATOMEntry(atom::entryValuesToElements(c)), "application/atom+xml", r);
+    if (isList(car<value>(e)) && !isNil(car<value>(e))) {
+        const list<value> el = car<value>(e);
+        if (isSymbol(car<value>(el)) && car<value>(el) == element && !isNil(cdr<value>(el)) && isSymbol(cadr<value>(el))) {
+            if (cadr<value>(el) == atom::feed)
+                return httpd::writeResult(atom::writeATOMFeed(e), "application/atom+xml", r);
+            if (cadr<value>(el) == atom::entry)
+                return httpd::writeResult(atom::writeATOMEntry(e), "application/atom+xml", r);
+        }
     }
 
     // Write any other compound value as a JSON value
     js::JSContext cx;
-    return httpd::writeResult(json::writeJSON(valuesToElements(c), cx), "application/json", r);
+    return httpd::writeResult(json::writeJSON(e, cx), "application/json", r);
 }
 
 /**
@@ -210,7 +217,7 @@ const failable<int> post(request_rec* r,
             return rc;
         const list<string> ls = httpd::read(r);
         debug(ls, "modeval::post::input");
-        const value entry = atom::entryValue(content(atom::readATOMEntry(ls)));
+        const value entry = elementsToValues(content(atom::readATOMEntry(ls)));
 
         // Evaluate the POST expression
         const failable<value> val = failableResult(impl(cons<value>("post", mklist<value>(cddr(path), entry))));
@@ -245,7 +252,7 @@ const failable<int> put(request_rec* r, 
         return rc;
     const list<string> ls = httpd::read(r);
     debug(ls, "modeval::put::input");
-    const value entry = atom::entryValue(content(atom::readATOMEntry(ls)));
+    const value entry = elementsToValues(content(atom::readATOMEntry(ls)));
 
     // Evaluate the PUT expression and update the corresponding resource
     const failable<value> val = failableResult(impl(cons<value>("put", mklist<value>(cddr(path), entry))));

Modified: tuscany/sca-cpp/trunk/modules/server/server-test.scm
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/modules/server/server-test.scm?rev=1079292&r1=1079291&r2=1079292&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/modules/server/server-test.scm (original)
+++ tuscany/sca-cpp/trunk/modules/server/server-test.scm Tue Mar  8 08:18:07 2011
@@ -23,12 +23,12 @@
 
 (define (get id)
   (if (nul id)
-    '("Sample Feed" "123456789"
-      ("Item" "111" ((name "Apple") (currencyCode "USD") (currencySymbol "$") (price 2.99)))
-      ("Item" "222" ((name "Orange") (currencyCode "USD") (currencySymbol "$") (price 3.55)))
-      ("Item" "333" ((name "Pear") (currencyCode "USD") (currencySymbol "$") (price 1.55))))
+    '((feed (title "Sample Feed") (id "123456789") (entry
+       (((title "Item") (id "111") (content (item (name "Apple") (currencyCode "USD") (currencySymbol "$") (price 2.99))))
+        ((title "Item") (id "222") (content (item (name "Orange") (currencyCode "USD") (currencySymbol "$") (price 3.55))))
+        ((title "Item") (id "333") (content (item (name "Pear") (currencyCode "USD") (currencySymbol "$") (price 1.55))))))))
     
-    (list "Item" (car id) '((name "Apple") (currencyCode "USD") (currencySymbol "$") (price 2.99))))
+    (list (list 'entry '(title "Item") (list 'id (car id)) '(content (item (name "Apple") (currencyCode "USD") (currencySymbol "$") (price 2.99))))))
 )
 
 (define (post collection item)

Modified: tuscany/sca-cpp/trunk/modules/wsgi/atom-test.py
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/modules/wsgi/atom-test.py?rev=1079292&r1=1079291&r2=1079292&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/modules/wsgi/atom-test.py (original)
+++ tuscany/sca-cpp/trunk/modules/wsgi/atom-test.py Tue Mar  8 08:18:07 2011
@@ -71,7 +71,7 @@ completedEntry = \
 
 def testEntry():
     i = (element, "'item", (element, "'name", "Apple"), (element, "'price", "$2.99"))
-    a = ("item", "cart-53d67a61-aa5e-4e5e-8401-39edeba8b83b", i)
+    a = ((element, "'entry", (element, "'title", "item"), (element, "'id", "cart-53d67a61-aa5e-4e5e-8401-39edeba8b83b"), (element, "'content", i)),)
     s = writeATOMEntry(a);
     assert car(s) == itemEntry
 
@@ -123,41 +123,29 @@ itemFeed = \
     "</feed>\n"
 
 def testFeed():
-    s = writeATOMFeed(("Feed", "1234"))
+    a = ((element, "'feed", (element, "'title", "Feed"), (element, "'id", "1234")),)
+    s = writeATOMFeed(a)
     assert car(s) == emptyFeed
 
     a2 = readATOMFeed((emptyFeed,))
     s2 = writeATOMFeed(a2)
     assert car(s2) == emptyFeed
 
-    i3 = (("item", "cart-53d67a61-aa5e-4e5e-8401-39edeba8b83b",
-            (element, "'item", (element, "'name", "Apple"), (element, "'price", "$2.99"))),
-          ("item", "cart-53d67a61-aa5e-4e5e-8401-39edeba8b83c",
-            (element, "'item", (element, "'name", "Orange"), (element, "'price", "$3.55"))))
-    a3 = cons("Feed", cons("1234", i3))
+    i3 = ((element, "'entry", (element, "'title", "item"), (element, "'id", "cart-53d67a61-aa5e-4e5e-8401-39edeba8b83b"),
+            (element, "'content", (element, "'item", (element, "'name", "Apple"), (element, "'price", "$2.99")))),
+          (element, "'entry", (element, "'title", "item"), (element, "'id", "cart-53d67a61-aa5e-4e5e-8401-39edeba8b83c"),
+            (element, "'content", (element, "'item", (element, "'name", "Orange"), (element, "'price", "$3.55")))))
+    a3 = (append((element, "'feed", (element, "'title", "Feed"), (element, "'id", "1234")), i3),)
     s3 = writeATOMFeed(a3)
     assert car(s3) == itemFeed
 
-    i4 = (("item", "cart-53d67a61-aa5e-4e5e-8401-39edeba8b83b",
-            valueToElement(("'item", ("'name", "Apple"), ("'price", "$2.99")))),
-          ("item", "cart-53d67a61-aa5e-4e5e-8401-39edeba8b83c",
-            valueToElement(("'item", ("'name", "Orange"), ("'price", "$3.55")))))
-    a4 = cons("Feed", cons("1234", i4))
-    s4 = writeATOMFeed(a4)
+    a4 = readATOMFeed((itemFeed,));
+    s4 = writeATOMFeed(a4);
     assert car(s4) == itemFeed
 
-    a5 = readATOMFeed((itemFeed,));
-    s5 = writeATOMFeed(a5);
+    a5 = elementsToValues(readATOMFeed((itemFeed,)));
+    s5 = writeATOMFeed(valuesToElements(a5));
     assert car(s5) == itemFeed
-
-    i6 = (("item", "cart-53d67a61-aa5e-4e5e-8401-39edeba8b83b",
-            (("'name", "Apple"), ("'price", "$2.99"))),
-          ("item", "cart-53d67a61-aa5e-4e5e-8401-39edeba8b83c",
-            (("'name", "Orange"), ("'price", "$3.55"))))
-    a6 = cons("Feed", cons("1234", i6))
-    s6 = writeATOMFeed(feedValuesToElements(a6))
-    assert car(s6) == itemFeed
-
     return True
 
 if __name__ == "__main__":

Modified: tuscany/sca-cpp/trunk/modules/wsgi/atomutil.py
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/modules/wsgi/atomutil.py?rev=1079292&r1=1079291&r2=1079292&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/modules/wsgi/atomutil.py (original)
+++ tuscany/sca-cpp/trunk/modules/wsgi/atomutil.py Tue Mar  8 08:18:07 2011
@@ -22,31 +22,27 @@ from elemutil import *
 from xmlutil import *
 
 # Convert a list of elements to a list of values representing an ATOM entry
-def entryElementsToValues(e):
+def entryElementValues(e):
     lt = filter(selector((element, "'title")), e)
     t = "" if isNil(lt) else elementValue(car(lt))
     li = filter(selector((element, "'id")), e)
     i = "" if isNil(li) else elementValue(car(li))
     lc = filter(selector((element, "'content")), e)
-    return (t, i, elementValue(car(lc)))
+    return append((element, "'entry", (element, "'title", t), (element, "'id", i)),
+            () if isNil(lc) else ((element, "'content", elementValue(car(lc))),))
 
 # Convert a list of elements to a list of values representing ATOM entries
-def entriesElementsToValues(e):
+def entriesElementValues(e):
     if isNil(e):
         return e
-    return cons(entryElementsToValues(car(e)), entriesElementsToValues(cdr(e)))
+    return cons(entryElementValues(car(e)), entriesElementValues(cdr(e)))
 
 # Convert a list of strings to a list of values representing an ATOM entry
 def readATOMEntry(l):
     e = readXML(l)
     if isNil(e):
         return ()
-    return entryElementsToValues(car(e))
-
-# Convert a list of values representing an ATOM entry to a value
-def entryValue(e):
-    v = elementsToValues((caddr(e),))
-    return cons(car(e), (cadr(e), cdr(car(v))))
+    return (entryElementValues(car(e)),)
 
 # Return true if a list of strings represents an ATOM feed
 def isATOMFeed(l):
@@ -68,26 +64,23 @@ def readATOMFeed(l):
     t = filter(selector((element, "'title")), car(f))
     i = filter(selector((element, "'id")), car(f))
     e = filter(selector((element, "'entry")), car(f))
-    if isNil(e):
-        return (elementValue(car(t)), elementValue(car(i)))
-    return cons(elementValue(car(t)), cons(elementValue(car(i)), entriesElementsToValues(e)))
-
-# Convert an ATOM feed containing elements to an ATOM feed containing values
-def feedValuesLoop(e):
-    if (isNil(e)):
-        return e
-    return cons(entryValue(car(e)), feedValuesLoop(cdr(e)))
-
-def feedValues(e):
-    return cons(car(e), cons(cadr(e), feedValuesLoop(cddr(e))))
+    return (append(
+                (element, "'feed", (element, "'title", elementValue(car(t))), (element, "'id", elementValue(car(i)))),
+                entriesElementValues(e)),)
 
 # Convert a list of values representy an ATOM entry to a list of elements
 def entryElement(l):
-    return (element, "'entry", (attribute, "'xmlns", "http://www.w3.org/2005/Atom"),
-            (element, "'title", (attribute, "'type", "text"), car(l)),
-            (element, "'id", cadr(l)),
-            (element, "'content", (attribute, "'type", ("application/xml" if isList(caddr(l)) else "text")), caddr(l)),
-            (element, "'link", (attribute, "'href", cadr(l))))
+    title = elementValue(namedElementChild("'title", l))
+    id = elementValue(namedElementChild("'id", l))
+    content = namedElementChild("'content", l)
+    text = False if isNil(content) else elementHasValue(content)
+    return append(append(
+            (element, "'entry", (attribute, "'xmlns", "http://www.w3.org/2005/Atom"),
+             (element, "'title", (attribute, "'type", "text"), title),
+             (element, "'id", id)),
+            () if isNil(content) else (append(
+                (element, "'content", (attribute, "'type", "text" if text else "application/xml")), (elementValue(content),) if text else elementChildren(content)),)),
+            ((element, "'link", (attribute, "'href", id)),))
 
 # Convert a list of values representing ATOM entries to a list of elements
 def entriesElements(l):
@@ -96,31 +89,32 @@ def entriesElements(l):
     return cons(entryElement(car(l)), entriesElements(cdr(l)))
 
 # Convert a list of values representing an ATOM entry to an ATOM entry
-def writeATOMEntry(l):
+def writeATOMEntry(ll):
+    l = ll if isNil(ll) else car(ll)
     return writeXML((entryElement(l),), True)
 
 # Convert a list of values representing an ATOM feed to an ATOM feed
-def writeATOMFeed(l):
+def writeATOMFeed(ll):
+    l = ll if isNil(ll) else car(ll)
+    lt = filter(selector((element, "'title")), l)
+    t = '' if isNil(lt) else elementValue(car(lt))
+    li = filter(selector((element, "'id")), l)
+    i = '' if isNil(li) else elementValue(car(li))
     f = (element, "'feed", (attribute, "'xmlns", "http://www.w3.org/2005/Atom"),
-            (element, "'title", (attribute, "'type", "text"), car(l)),
-            (element, "'id", cadr(l)))
-    if isNil(cddr(l)):
+            (element, "'title", (attribute, "'type", "text"), t),
+            (element, "'id", i))
+
+    # Write ATOM entries
+    le = filter(selector((element, "'entry")), l)
+    if isNil(le):
         return writeXML((f,), True)
-    fe = append(f, entriesElements(cddr(l)))
-    return writeXML((fe,), True)
 
-# Convert an ATOM entry containing a value to an ATOM entry containing an item element
-def entryValuesToElements(v):
-    if isList(caddr(v)):
-        return cons(car(v), cons(cadr(v), valuesToElements((cons("'item", caddr(v)),))))
-    return cons(car(v), cons(cadr(v), valuesToElements((("'item", caddr(v)),))))
-
-# Convert an ATOM feed containing values to an ATOM feed containing elements
-def feedValuesToElementsLoop(v):
-    if isNil(v):
-        return v
-    return cons(entryValuesToElements(car(v)), feedValuesToElementsLoop(cdr(v)))
+    # Write a single ATOM entry element with a list of values
+    if not isNil(le) and not isNil(car(le)) and isList(car(caddr(car(le)))):
+        fe = append(f, entriesElements(caddr(car(le))))
+        return writeXML((fe,), True)
 
-def feedValuesToElements(v):
-    return cons(car(v), cons(cadr(v), feedValuesToElementsLoop(cddr(v))))
+    # Write separate ATOM entry elements
+    fe = append(f, entriesElements(le))
+    return writeXML((fe,), True)
 

Modified: tuscany/sca-cpp/trunk/modules/wsgi/composite.py
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/modules/wsgi/composite.py?rev=1079292&r1=1079291&r2=1079292&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/modules/wsgi/composite.py (original)
+++ tuscany/sca-cpp/trunk/modules/wsgi/composite.py Tue Mar  8 08:18:07 2011
@@ -179,18 +179,32 @@ def application(e, r):
     if m == "GET":
         v = comp("get", id)
         
+        # Write a simple value as a JSON value
+        if not isList(v):
+            return result(e, r, 200, (("Content-type", "application/json"),), writeJSON(valuesToElements((("'value", v),))))
+
+        # Write an empty list as a JSON empty value
+        if not isList(v):
+            return result(e, r, 200, (("Content-type", "application/json"),), writeJSON(()))
+
         # Write content-type / content-list pair
-        if isString(car(v)) and isList(cadr(v)):
+        if isString(car(v)) and not isNil(cdr(v)) and isList(cadr(v)):
             return result(e, r, 200, (("Content-type", car(v)),), cadr(v))
         
-        # Write an ATOM feed or entry
-        if isString(car(v)) and isString(cadr(v)):
-            if isNil(id):
-                return result(e, r, 200, (("Content-type", "application/atom+xml"),), writeATOMFeed(feedValuesToElements(v)))
-            return result(e, r, 200, (("Content-type", "application/atom+xml"),), writeATOMEntry(entryValuesToElements(v)))
+        # Convert list of values to element values
+        ve = valuesToElements(v)
+
+        # Write an assoc result as a JSON value
+        if isList(car(ve)) and not isNil(car(ve)):
+            el = car(ve)
+            if isSymbol(car(el)) and car(el) == element and not isNil(cdr(el)) and isSymbol(cadr(el)):
+                if cadr(el) == "'feed":
+                    return result(e, r, 200, (("Content-type", "application/atom+xml"),), writeATOMFeed(ve))
+                if cadr(el) == "'entry":
+                    return result(e, r, 200, (("Content-type", "application/atom+xml"),), writeATOMEntry(ve))
 
         # Write a JSON value
-        return result(e, r, 200, (("Content-type", "application/json"),), writeJSON(valuesToElements(v)))
+        return result(e, r, 200, (("Content-type", "application/json"),), writeJSON(ve))
 
     if m == "POST":
         ct = requestContentType(e)
@@ -208,7 +222,7 @@ def application(e, r):
 
         # Handle an ATOM entry POST
         if contains(ct, "application/atom+xml"):
-            ae = entryValue(readATOMEntry(requestBody(e)))
+            ae = elementsToValues(readATOMEntry(requestBody(e)))
             v = comp("post", id, ae)
             if isNil(v):
                 return failure(e, r, 500)
@@ -217,7 +231,7 @@ def application(e, r):
     
     if m == "PUT":
         # Handle an ATOM entry PUT
-        ae = entryValue(readATOMEntry(requestBody(e)))
+        ae = elementsToValues(readATOMEntry(requestBody(e)))
         v = comp("put", id, ae)
         if v == False:
             return failure(e, r, 404)

Modified: tuscany/sca-cpp/trunk/modules/wsgi/server-test.py
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/modules/wsgi/server-test.py?rev=1079292&r1=1079291&r2=1079292&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/modules/wsgi/server-test.py (original)
+++ tuscany/sca-cpp/trunk/modules/wsgi/server-test.py Tue Mar  8 08:18:07 2011
@@ -25,14 +25,15 @@ def echo(x):
 def get(id):
     if id == ("index.html",):
         return ("text/plain", ("It works!",))
+
     if id == ():
-        return ("Sample Feed", "123456789",
-            ("Item", "111", (("'name", "Apple"), ("'currencyCode", "USD"), ("'currencySymbol", "$"), ("'price", 2.99))),
-            ("Item", "222", (("'name", "Orange"), ("'currencyCode", "USD"), ("'currencySymbol", "$"), ("'price", 3.55))),
-            ("Item", "333", (("'name", "Pear"), ("'currencyCode", "USD"), ("'currencySymbol", "$"), ("'price", 1.55))))
-        
-    entry = (("'name", "Apple"), ("'currencyCode", "USD"), ("'currencySymbol", "$"), ("'price", 2.99))
-    return ("Item", id[0], entry)
+        return (("'feed", ("'title", "Sample Feed"), ("'id", "123456789"), ("'entry", 
+            ((("'title", "Item"), ("'id", "111"), ("'content", ("'item", ("'name", "Apple"), ("'currencyCode", "USD"), ("'currencySymbol", "$"), ("'price", 2.99)))),
+             (("'title", "Item"), ("'id", "222"), ("'content", ("'item", ("'name", "Orange"), ("'currencyCode", "USD"), ("'currencySymbol", "$"), ("'price", 3.55)))),
+             (("'title", "Item"), ("'id", "333"), ("'content", ("'item", ("'name", "Pear"), ("'currencyCode", "USD"), ("'currencySymbol", "$"), ("'price", 1.55))))))),)
+
+    content = ("'content", ("'item", ("'name", "Apple"), ("'currencyCode", "USD"), ("'currencySymbol", "$"), ("'price", 2.99)))
+    return (("'entry", ("'title", "Item"), ("'id", id[0]), content),)
 
 def post(collection, item):
     return ("123456789",)

Modified: tuscany/sca-cpp/trunk/modules/wsgi/util.py
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/modules/wsgi/util.py?rev=1079292&r1=1079291&r2=1079292&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/modules/wsgi/util.py (original)
+++ tuscany/sca-cpp/trunk/modules/wsgi/util.py Tue Mar  8 08:18:07 2011
@@ -43,6 +43,12 @@ def cddr(l):
 def caddr(l):
     return car(cddr(l))
 
+def cdddr(l):
+    return cdr(cdr(cdr(l)))
+
+def cadddr(l):
+    return car(cdddr(l))
+
 def append(a, b):
     return a + b
 

Modified: tuscany/sca-cpp/trunk/samples/store-cluster/domains/jane/htdocs/index.html
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/samples/store-cluster/domains/jane/htdocs/index.html?rev=1079292&r1=1079291&r2=1079292&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/samples/store-cluster/domains/jane/htdocs/index.html (original)
+++ tuscany/sca-cpp/trunk/samples/store-cluster/domains/jane/htdocs/index.html Tue Mar  8 08:18:07 2011
@@ -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, ex
 
 }
 
-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++) {

Modified: tuscany/sca-cpp/trunk/samples/store-cluster/domains/jane/shopping-cart.py
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/samples/store-cluster/domains/jane/shopping-cart.py?rev=1079292&r1=1079291&r2=1079292&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/samples/store-cluster/domains/jane/shopping-cart.py (original)
+++ tuscany/sca-cpp/trunk/samples/store-cluster/domains/jane/shopping-cart.py Tue Mar  8 08:18:07 2011
@@ -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, 
 # 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):

Modified: tuscany/sca-cpp/trunk/samples/store-cluster/domains/joe/htdocs/index.html
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/samples/store-cluster/domains/joe/htdocs/index.html?rev=1079292&r1=1079291&r2=1079292&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/samples/store-cluster/domains/joe/htdocs/index.html (original)
+++ tuscany/sca-cpp/trunk/samples/store-cluster/domains/joe/htdocs/index.html Tue Mar  8 08:18:07 2011
@@ -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, ex
 
 }
 
-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++) {

Modified: tuscany/sca-cpp/trunk/samples/store-cluster/domains/joe/shopping-cart.py
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/samples/store-cluster/domains/joe/shopping-cart.py?rev=1079292&r1=1079291&r2=1079292&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/samples/store-cluster/domains/joe/shopping-cart.py (original)
+++ tuscany/sca-cpp/trunk/samples/store-cluster/domains/joe/shopping-cart.py Tue Mar  8 08:18:07 2011
@@ -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, 
 # 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):

Modified: tuscany/sca-cpp/trunk/samples/store-cpp/htdocs/index.html
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/samples/store-cpp/htdocs/index.html?rev=1079292&r1=1079291&r2=1079292&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/samples/store-cpp/htdocs/index.html (original)
+++ tuscany/sca-cpp/trunk/samples/store-cpp/htdocs/index.html Tue Mar  8 08:18:07 2011
@@ -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, ex
 
 }
 
-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++) {

Modified: tuscany/sca-cpp/trunk/samples/store-cpp/shopping-cart.cpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/samples/store-cpp/shopping-cart.cpp?rev=1079292&r1=1079291&r2=1079292&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/samples/store-cpp/shopping-cart.cpp (original)
+++ tuscany/sca-cpp/trunk/samples/store-cpp/shopping-cart.cpp Tue Mar  8 08:18:07 2011
@@ -55,7 +55,7 @@ const list<value> getcart(const value& i
  */
 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 
  */
 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 
  */
 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<val
  * 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)))));
 }
 
 /**

Modified: tuscany/sca-cpp/trunk/samples/store-gae/htdocs/index.html
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/samples/store-gae/htdocs/index.html?rev=1079292&r1=1079291&r2=1079292&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/samples/store-gae/htdocs/index.html (original)
+++ tuscany/sca-cpp/trunk/samples/store-gae/htdocs/index.html Tue Mar  8 08:18:07 2011
@@ -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(emai
     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++) {

Modified: tuscany/sca-cpp/trunk/samples/store-gae/shopping-cart.py
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/samples/store-gae/shopping-cart.py?rev=1079292&r1=1079291&r2=1079292&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/samples/store-gae/shopping-cart.py (original)
+++ tuscany/sca-cpp/trunk/samples/store-gae/shopping-cart.py Tue Mar  8 08:18:07 2011
@@ -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):

Modified: tuscany/sca-cpp/trunk/samples/store-java/htdocs/index.html
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/samples/store-java/htdocs/index.html?rev=1079292&r1=1079291&r2=1079292&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/samples/store-java/htdocs/index.html (original)
+++ tuscany/sca-cpp/trunk/samples/store-java/htdocs/index.html Tue Mar  8 08:18:07 2011
@@ -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, ex
 
 }
 
-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++) {

Modified: tuscany/sca-cpp/trunk/samples/store-java/store/ShoppingCartImpl.java
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/samples/store-java/store/ShoppingCartImpl.java?rev=1079292&r1=1079291&r2=1079292&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/samples/store-java/store/ShoppingCartImpl.java (original)
+++ tuscany/sca-cpp/trunk/samples/store-java/store/ShoppingCartImpl.java Tue Mar  8 08:18:07 2011
@@ -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))))));
     }
 
     /**

Modified: tuscany/sca-cpp/trunk/samples/store-nosql/htdocs/index.html
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/samples/store-nosql/htdocs/index.html?rev=1079292&r1=1079291&r2=1079292&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/samples/store-nosql/htdocs/index.html (original)
+++ tuscany/sca-cpp/trunk/samples/store-nosql/htdocs/index.html Tue Mar  8 08:18:07 2011
@@ -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, ex
 
 }
 
-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++) {

Modified: tuscany/sca-cpp/trunk/samples/store-nosql/shopping-cart.scm
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/samples/store-nosql/shopping-cart.scm?rev=1079292&r1=1079291&r2=1079292&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/samples/store-nosql/shopping-cart.scm (original)
+++ tuscany/sca-cpp/trunk/samples/store-nosql/shopping-cart.scm Tue Mar  8 08:18:07 2011
@@ -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

Modified: tuscany/sca-cpp/trunk/samples/store-python/htdocs/index.html
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/samples/store-python/htdocs/index.html?rev=1079292&r1=1079291&r2=1079292&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/samples/store-python/htdocs/index.html (original)
+++ tuscany/sca-cpp/trunk/samples/store-python/htdocs/index.html Tue Mar  8 08:18:07 2011
@@ -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, ex
 
 }
 
-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++) {

Modified: tuscany/sca-cpp/trunk/samples/store-python/shopping-cart.py
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/samples/store-python/shopping-cart.py?rev=1079292&r1=1079291&r2=1079292&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/samples/store-python/shopping-cart.py (original)
+++ tuscany/sca-cpp/trunk/samples/store-python/shopping-cart.py Tue Mar  8 08:18:07 2011
@@ -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):

Modified: tuscany/sca-cpp/trunk/samples/store-scheme/htdocs/index.html
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/samples/store-scheme/htdocs/index.html?rev=1079292&r1=1079291&r2=1079292&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/samples/store-scheme/htdocs/index.html (original)
+++ tuscany/sca-cpp/trunk/samples/store-scheme/htdocs/index.html Tue Mar  8 08:18:07 2011
@@ -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, ex
 
 }
 
-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++) {

Modified: tuscany/sca-cpp/trunk/samples/store-scheme/shopping-cart.scm
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/samples/store-scheme/shopping-cart.scm?rev=1079292&r1=1079291&r2=1079292&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/samples/store-scheme/shopping-cart.scm (original)
+++ tuscany/sca-cpp/trunk/samples/store-scheme/shopping-cart.scm Tue Mar  8 08:18:07 2011
@@ -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

Modified: tuscany/sca-cpp/trunk/samples/store-sql/htdocs/index.html
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/samples/store-sql/htdocs/index.html?rev=1079292&r1=1079291&r2=1079292&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/samples/store-sql/htdocs/index.html (original)
+++ tuscany/sca-cpp/trunk/samples/store-sql/htdocs/index.html Tue Mar  8 08:18:07 2011
@@ -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, ex
 
 }
 
-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++) {

Modified: tuscany/sca-cpp/trunk/samples/store-sql/shopping-cart.scm
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/samples/store-sql/shopping-cart.scm?rev=1079292&r1=1079291&r2=1079292&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/samples/store-sql/shopping-cart.scm (original)
+++ tuscany/sca-cpp/trunk/samples/store-sql/shopping-cart.scm Tue Mar  8 08:18:07 2011
@@ -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

Modified: tuscany/sca-cpp/trunk/samples/store-vhost/domains/jane/htdocs/index.html
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/samples/store-vhost/domains/jane/htdocs/index.html?rev=1079292&r1=1079291&r2=1079292&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/samples/store-vhost/domains/jane/htdocs/index.html (original)
+++ tuscany/sca-cpp/trunk/samples/store-vhost/domains/jane/htdocs/index.html Tue Mar  8 08:18:07 2011
@@ -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, ex
 
 }
 
-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++) {

Modified: tuscany/sca-cpp/trunk/samples/store-vhost/domains/jane/shopping-cart.py
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/samples/store-vhost/domains/jane/shopping-cart.py?rev=1079292&r1=1079291&r2=1079292&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/samples/store-vhost/domains/jane/shopping-cart.py (original)
+++ tuscany/sca-cpp/trunk/samples/store-vhost/domains/jane/shopping-cart.py Tue Mar  8 08:18:07 2011
@@ -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):

Modified: tuscany/sca-cpp/trunk/samples/store-vhost/domains/joe/htdocs/index.html
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/samples/store-vhost/domains/joe/htdocs/index.html?rev=1079292&r1=1079291&r2=1079292&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/samples/store-vhost/domains/joe/htdocs/index.html (original)
+++ tuscany/sca-cpp/trunk/samples/store-vhost/domains/joe/htdocs/index.html Tue Mar  8 08:18:07 2011
@@ -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, ex
 
 }
 
-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++) {

Modified: tuscany/sca-cpp/trunk/samples/store-vhost/domains/joe/shopping-cart.py
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/samples/store-vhost/domains/joe/shopping-cart.py?rev=1079292&r1=1079291&r2=1079292&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/samples/store-vhost/domains/joe/shopping-cart.py (original)
+++ tuscany/sca-cpp/trunk/samples/store-vhost/domains/joe/shopping-cart.py Tue Mar  8 08:18:07 2011
@@ -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):