summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68>2010-12-24 04:35:53 +0000
committerjsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68>2010-12-24 04:35:53 +0000
commit86fa951ba99a04edf6a41b04751a1ad679dc2d36 (patch)
treec366d8560cf95210f8c2400fdec76652142950f9
parent150feb74a6f2897d860be360cedf641e004f5ca8 (diff)
Apply roundtripping fixes from SVN r1052432 to Python and Javascript scripts.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1052445 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--sca-cpp/trunk/modules/js/htdocs/atomutil.js10
-rw-r--r--sca-cpp/trunk/modules/js/htdocs/elemutil.js2
-rw-r--r--sca-cpp/trunk/modules/js/htdocs/xmlutil.js11
-rw-r--r--sca-cpp/trunk/modules/rss/rss.hpp2
-rw-r--r--sca-cpp/trunk/modules/wsgi/atomutil.py10
-rw-r--r--sca-cpp/trunk/modules/wsgi/elemutil.py2
-rw-r--r--sca-cpp/trunk/modules/wsgi/jsonutil.py14
-rw-r--r--sca-cpp/trunk/modules/wsgi/rssutil.py4
-rw-r--r--sca-cpp/trunk/modules/wsgi/xmlutil.py8
-rw-r--r--sca-cpp/trunk/samples/store-gae/Makefile.am7
10 files changed, 47 insertions, 23 deletions
diff --git a/sca-cpp/trunk/modules/js/htdocs/atomutil.js b/sca-cpp/trunk/modules/js/htdocs/atomutil.js
index 3499948083..6b998dceda 100644
--- a/sca-cpp/trunk/modules/js/htdocs/atomutil.js
+++ b/sca-cpp/trunk/modules/js/htdocs/atomutil.js
@@ -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))))));
};
/**
diff --git a/sca-cpp/trunk/modules/js/htdocs/elemutil.js b/sca-cpp/trunk/modules/js/htdocs/elemutil.js
index 6bebc02101..00baab06c8 100644
--- a/sca-cpp/trunk/modules/js/htdocs/elemutil.js
+++ b/sca-cpp/trunk/modules/js/htdocs/elemutil.js
@@ -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);
diff --git a/sca-cpp/trunk/modules/js/htdocs/xmlutil.js b/sca-cpp/trunk/modules/js/htdocs/xmlutil.js
index 121bf8692c..1bec45f9b9 100644
--- a/sca-cpp/trunk/modules/js/htdocs/xmlutil.js
+++ b/sca-cpp/trunk/modules/js/htdocs/xmlutil.js
@@ -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)));
diff --git a/sca-cpp/trunk/modules/rss/rss.hpp b/sca-cpp/trunk/modules/rss/rss.hpp
index 732b3a178d..506d1f4a6d 100644
--- a/sca-cpp/trunk/modules/rss/rss.hpp
+++ b/sca-cpp/trunk/modules/rss/rss.hpp
@@ -62,7 +62,7 @@ const list<value> entriesElementsToValues(const list<value>& e) {
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");
}
/**
diff --git a/sca-cpp/trunk/modules/wsgi/atomutil.py b/sca-cpp/trunk/modules/wsgi/atomutil.py
index 6c0a7c9a81..1e6a7c31b5 100644
--- a/sca-cpp/trunk/modules/wsgi/atomutil.py
+++ b/sca-cpp/trunk/modules/wsgi/atomutil.py
@@ -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):
diff --git a/sca-cpp/trunk/modules/wsgi/elemutil.py b/sca-cpp/trunk/modules/wsgi/elemutil.py
index ad971ba6ba..b4b28d5110 100644
--- a/sca-cpp/trunk/modules/wsgi/elemutil.py
+++ b/sca-cpp/trunk/modules/wsgi/elemutil.py
@@ -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)
diff --git a/sca-cpp/trunk/modules/wsgi/jsonutil.py b/sca-cpp/trunk/modules/wsgi/jsonutil.py
index f69559de54..ad8f5fcc6b 100644
--- a/sca-cpp/trunk/modules/wsgi/jsonutil.py
+++ b/sca-cpp/trunk/modules/wsgi/jsonutil.py
@@ -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,)
diff --git a/sca-cpp/trunk/modules/wsgi/rssutil.py b/sca-cpp/trunk/modules/wsgi/rssutil.py
index 4f060d2321..984d71b690 100644
--- a/sca-cpp/trunk/modules/wsgi/rssutil.py
+++ b/sca-cpp/trunk/modules/wsgi/rssutil.py
@@ -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")
diff --git a/sca-cpp/trunk/modules/wsgi/xmlutil.py b/sca-cpp/trunk/modules/wsgi/xmlutil.py
index a1bc04629a..35ccb7f803 100644
--- a/sca-cpp/trunk/modules/wsgi/xmlutil.py
+++ b/sca-cpp/trunk/modules/wsgi/xmlutil.py
@@ -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):
diff --git a/sca-cpp/trunk/samples/store-gae/Makefile.am b/sca-cpp/trunk/samples/store-gae/Makefile.am
index a472e3d9f6..09d5b516cf 100644
--- a/sca-cpp/trunk/samples/store-gae/Makefile.am
+++ b/sca-cpp/trunk/samples/store-gae/Makefile.am
@@ -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