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 2010/12/24 05:35:53 UTC

svn commit: r1052445 - in /tuscany/sca-cpp/trunk: modules/js/htdocs/ modules/rss/ modules/wsgi/ samples/store-gae/

Author: jsdelfino
Date: Fri Dec 24 04:35:53 2010
New Revision: 1052445

URL: http://svn.apache.org/viewvc?rev=1052445&view=rev
Log:
Apply roundtripping fixes from SVN r1052432 to Python and Javascript scripts.

Modified:
    tuscany/sca-cpp/trunk/modules/js/htdocs/atomutil.js
    tuscany/sca-cpp/trunk/modules/js/htdocs/elemutil.js
    tuscany/sca-cpp/trunk/modules/js/htdocs/xmlutil.js
    tuscany/sca-cpp/trunk/modules/rss/rss.hpp
    tuscany/sca-cpp/trunk/modules/wsgi/atomutil.py
    tuscany/sca-cpp/trunk/modules/wsgi/elemutil.py
    tuscany/sca-cpp/trunk/modules/wsgi/jsonutil.py
    tuscany/sca-cpp/trunk/modules/wsgi/rssutil.py
    tuscany/sca-cpp/trunk/modules/wsgi/xmlutil.py
    tuscany/sca-cpp/trunk/samples/store-gae/Makefile.am

Modified: tuscany/sca-cpp/trunk/modules/js/htdocs/atomutil.js
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/modules/js/htdocs/atomutil.js?rev=1052445&r1=1052444&r2=1052445&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/modules/js/htdocs/atomutil.js (original)
+++ tuscany/sca-cpp/trunk/modules/js/htdocs/atomutil.js Fri Dec 24 04:35:53 2010
@@ -65,11 +65,9 @@ atom.entryValue = function(e) {
  * Return true if a list of strings represents an ATOM feed.
  */
 atom.isATOMFeed = function(l) {
-    if (isNil(l))
-        return false;
-    if (car(l).substring(0, 5) != "<?xml")
+    if (!isXML(l))
         return false;
-    return car(l).match("<feed") != null;
+    return car(l).match('<feed') != null && car(l).match('="http://www.w3.org/2005/Atom"') != null;
 };
 
 /**
@@ -151,7 +149,9 @@ atom.writeATOMFeed = function(l) {
  * Convert an ATOM entry containing a value to an ATOM entry containing an item element.
  */
 atom.entryValuesToElements = function(v) {
-    return cons(car(v), cons(cadr(v), valuesToElements(mklist(cons("'item", caddr(v))))));
+    if (isList(caddr(v)))
+        return cons(car(v), cons(cadr(v), valuesToElements(mklist(cons("'item", caddr(v))))));
+    return cons(car(v), cons(cadr(v), valuesToElements(mklist(mklist("'item", caddr(v))))));
 };
 
 /**

Modified: tuscany/sca-cpp/trunk/modules/js/htdocs/elemutil.js
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/modules/js/htdocs/elemutil.js?rev=1052445&r1=1052444&r2=1052445&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/modules/js/htdocs/elemutil.js (original)
+++ tuscany/sca-cpp/trunk/modules/js/htdocs/elemutil.js Fri Dec 24 04:35:53 2010
@@ -161,7 +161,7 @@ function elementsToValues(e) {
 function valueToElement(t) {
     if (isList(t) && !isNil(t) && isSymbol(car(t))) {
         var n = car(t);
-        var v = cadr(t)
+        var v = isNil(cdr(t))? mklist() : cadr(t);
         if (!isList(v)) {
             if (n.substring(0, 2) == atsign)
                 return mklist(attribute, n.substring(1), v);

Modified: tuscany/sca-cpp/trunk/modules/js/htdocs/xmlutil.js
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/modules/js/htdocs/xmlutil.js?rev=1052445&r1=1052444&r2=1052445&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/modules/js/htdocs/xmlutil.js (original)
+++ tuscany/sca-cpp/trunk/modules/js/htdocs/xmlutil.js Fri Dec 24 04:35:53 2010
@@ -84,6 +84,15 @@ function readElements(l) {
 }
 
 /**
+ * Return true if a list of strings contains an XML document.
+ */
+function isXML(l) {
+    if (isNil(l))
+        return false;
+    return car(l).substring(0, 5) == '<?xml';
+}
+
+/**
  * Parse a list of strings representing an XML document.
  */
 function parseXML(l) {
@@ -107,7 +116,7 @@ function parseXML(l) {
  * Read a list of values from an XML document.
  */
 function readXMLDocument(doc) {
-    var root = nodeList(doc.childNodes);
+    var root = childElements(doc);
     if (isNil(root))
         return mklist();
     return mklist(readElement(car(root)));

Modified: tuscany/sca-cpp/trunk/modules/rss/rss.hpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/modules/rss/rss.hpp?rev=1052445&r1=1052444&r2=1052445&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/modules/rss/rss.hpp (original)
+++ tuscany/sca-cpp/trunk/modules/rss/rss.hpp Fri Dec 24 04:35:53 2010
@@ -62,7 +62,7 @@ const list<value> entriesElementsToValue
 const bool isRSSFeed(const list<string>& ls) {
     if (!isXML(ls))
         return false;
-    return contains(car(ls), "<rss") && contains(car(ls), "");
+    return contains(car(ls), "<rss");
 }
 
 /**

Modified: tuscany/sca-cpp/trunk/modules/wsgi/atomutil.py
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/modules/wsgi/atomutil.py?rev=1052445&r1=1052444&r2=1052445&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/modules/wsgi/atomutil.py (original)
+++ tuscany/sca-cpp/trunk/modules/wsgi/atomutil.py Fri Dec 24 04:35:53 2010
@@ -50,11 +50,9 @@ def entryValue(e):
 
 # Return true if a list of strings represents an ATOM feed
 def isATOMFeed(l):
-    if isNil(l):
-        return False
-    if car(l)[0:5] != "<?xml":
+    if not isXML(l):
         return False
-    return contains(car(l), "<feed")
+    return contains(car(l), "<feed") and contains(car(l), "=\"http://www.w3.org/2005/Atom\"")
 
 # Convert a list of strings to a list of values representing an ATOM feed
 def readATOMFeed(l):
@@ -107,7 +105,9 @@ def writeATOMFeed(l):
 
 # Convert an ATOM entry containing a value to an ATOM entry containing an item element
 def entryValuesToElements(v):
-    return cons(car(v), cons(cadr(v), valuesToElements((cons("'item", caddr(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):

Modified: tuscany/sca-cpp/trunk/modules/wsgi/elemutil.py
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/modules/wsgi/elemutil.py?rev=1052445&r1=1052444&r2=1052445&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/modules/wsgi/elemutil.py (original)
+++ tuscany/sca-cpp/trunk/modules/wsgi/elemutil.py Fri Dec 24 04:35:53 2010
@@ -117,7 +117,7 @@ def elementsToValues(e):
 def valueToElement(t):
     if isList(t) and not isNil(t) and isSymbol(car(t)):
         n = car(t)
-        v = cadr(t)
+        v = () if isNil(cdr(t)) else cadr(t)
         if not isList(v):
             if n[0:2] == atsign:
                 return (attribute, n[1:], v)

Modified: tuscany/sca-cpp/trunk/modules/wsgi/jsonutil.py
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/modules/wsgi/jsonutil.py?rev=1052445&r1=1052444&r2=1052445&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/modules/wsgi/jsonutil.py (original)
+++ tuscany/sca-cpp/trunk/modules/wsgi/jsonutil.py Fri Dec 24 04:35:53 2010
@@ -64,7 +64,14 @@ def jsValToValue(jsv):
     if isinstance(jsv, basestring):
         return str(jsv)
     return jsv
-    
+
+# Return true if a list of strings contains a JSON document
+def isJSON(l):
+    if isNil(l):
+        return False
+    s = car(l)[0:1]
+    return s == "[" or s == "{"
+
 # Convert a list of strings representing a JSON document to a list of values
 def readJSON(l):
     s = StringIO()
@@ -108,7 +115,10 @@ def valuesToJSProperties(o, l):
 
 # Convert a list of values to a list of strings representing a JSON document
 def writeJSON(l):
-    jsv = valuesToJSProperties({}, l)
+    if isJSArray(l):
+        jsv = valuesToJSElements(list(range(0, len(l))), l, 0)
+    else:
+        jsv = valuesToJSProperties({}, l)
     s = json.dumps(jsv, separators=(',',':'))
     return (s,)
 

Modified: tuscany/sca-cpp/trunk/modules/wsgi/rssutil.py
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/modules/wsgi/rssutil.py?rev=1052445&r1=1052444&r2=1052445&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/modules/wsgi/rssutil.py (original)
+++ tuscany/sca-cpp/trunk/modules/wsgi/rssutil.py Fri Dec 24 04:35:53 2010
@@ -50,9 +50,7 @@ def entryValue(e):
 
 # Return true if a list of strings represents an RSS feed
 def isRSSFeed(l):
-    if isNil(l):
-        return False
-    if car(l)[0:5] != "<?xml":
+    if not isXML(l):
         return False
     return contains(car(l), "<rss")
 

Modified: tuscany/sca-cpp/trunk/modules/wsgi/xmlutil.py
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/modules/wsgi/xmlutil.py?rev=1052445&r1=1052444&r2=1052445&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/modules/wsgi/xmlutil.py (original)
+++ tuscany/sca-cpp/trunk/modules/wsgi/xmlutil.py Fri Dec 24 04:35:53 2010
@@ -42,6 +42,14 @@ def readElements(l):
         return l
     return cons(readElement(car(l)), readElements(cdr(l)))
 
+# Return true if a list of strings represents an XML document
+def isXML(l):
+    if isNil(l):
+        return False
+    if car(l)[0:5] != "<?xml":
+        return False
+    return True
+
 # Parse a list of strings representing an XML document
 class NamespaceParser(et.XMLTreeBuilder):
     def __init__(self):

Modified: tuscany/sca-cpp/trunk/samples/store-gae/Makefile.am
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/samples/store-gae/Makefile.am?rev=1052445&r1=1052444&r2=1052445&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/samples/store-gae/Makefile.am (original)
+++ tuscany/sca-cpp/trunk/samples/store-gae/Makefile.am Fri Dec 24 04:35:53 2010
@@ -22,19 +22,18 @@ dist_sample_SCRIPTS = start stop
 sampledir = $(prefix)/samples/store-gae
 
 BUILT_SOURCES = target.stamp 
-target.stamp: app.yaml *.py *.composite $(top_builddir)/modules/wsgi/*.py htdocs/* $(top_builddir)/modules/server/htdocs/wiring/*
+target.stamp: app.yaml *.py *.composite $(top_builddir)/modules/wsgi/*.py htdocs/* $(top_builddir)/modules/js/htdocs/*
 	mkdir -p target
 	cp app.yaml *.py *.composite `ls $(top_builddir)/modules/wsgi/*.py | grep -v "\-test"` target
 	mkdir -p target/htdocs
 	cp -R htdocs/* target/htdocs
-	mkdir -p target/htdocs/wiring
-	cp -R $(top_builddir)/modules/server/htdocs/wiring/* target/htdocs/wiring
+	cp -R $(top_builddir)/modules/js/htdocs/* target/htdocs
 	touch target.stamp
 
 clean-local:
 	rm -rf target.stamp target
 
-nobase_sample_DATA = target/app.yaml target/*.py target/*.composite target/htdocs/*.html target/htdocs/wiring/*.js
+nobase_sample_DATA = target/app.yaml target/*.py target/*.composite target/htdocs/*.html target/htdocs/*.js
 
 EXTRA_DIST = app.yaml *.composite *.py htdocs/*.html