summaryrefslogtreecommitdiffstats
path: root/sca-cpp/trunk/modules/wsgi
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--sca-cpp/trunk/modules/wsgi/atomutil.py30
-rwxr-xr-xsca-cpp/trunk/modules/wsgi/composite.py12
-rw-r--r--sca-cpp/trunk/modules/wsgi/elemutil.py32
-rw-r--r--sca-cpp/trunk/modules/wsgi/jsonutil.py12
-rw-r--r--sca-cpp/trunk/modules/wsgi/rssutil.py20
-rw-r--r--sca-cpp/trunk/modules/wsgi/util.py12
-rw-r--r--sca-cpp/trunk/modules/wsgi/xmlutil.py6
7 files changed, 62 insertions, 62 deletions
diff --git a/sca-cpp/trunk/modules/wsgi/atomutil.py b/sca-cpp/trunk/modules/wsgi/atomutil.py
index 4b67ef216e..d65b26c41c 100644
--- a/sca-cpp/trunk/modules/wsgi/atomutil.py
+++ b/sca-cpp/trunk/modules/wsgi/atomutil.py
@@ -24,23 +24,23 @@ from xmlutil import *
# Convert a list of elements to a list of values representing an ATOM entry
def entryElementValues(e):
lt = filter(selector((element, "'title")), e)
- t = "" if isNil(lt) else elementValue(car(lt))
+ t = "" if isNull(lt) else elementValue(car(lt))
li = filter(selector((element, "'id")), e)
- i = "" if isNil(li) else elementValue(car(li))
+ i = "" if isNull(li) else elementValue(car(li))
lc = filter(selector((element, "'content")), e)
return append((element, "'entry", (element, "'title", t), (element, "'id", i)),
- () if isNil(lc) else () if isAttribute(elementValue(car(lc))) else ((element, "'content", elementValue(car(lc))),))
+ () if isNull(lc) else () if isAttribute(elementValue(car(lc))) else ((element, "'content", elementValue(car(lc))),))
# Convert a list of elements to a list of values representing ATOM entries
def entriesElementValues(e):
- if isNil(e):
+ if isNull(e):
return 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):
+ if isNull(e):
return ()
return (entryElementValues(car(e)),)
@@ -59,7 +59,7 @@ def isATOMEntry(l):
# Convert a list of strings to a list of values representing an ATOM feed
def readATOMFeed(l):
f = readXML(l)
- if isNil(f):
+ if isNull(f):
return ()
t = filter(selector((element, "'title")), car(f))
i = filter(selector((element, "'id")), car(f))
@@ -73,44 +73,44 @@ def entryElement(l):
title = elementValue(namedElementChild("'title", l))
id = elementValue(namedElementChild("'id", l))
content = namedElementChild("'content", l)
- text = False if isNil(content) else elementHasValue(content)
+ text = False if isNull(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(
+ () if isNull(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):
- if isNil(l):
+ if isNull(l):
return l
return cons(entryElement(car(l)), entriesElements(cdr(l)))
# Convert a list of values representing an ATOM entry to an ATOM entry
def writeATOMEntry(ll):
- l = ll if isNil(ll) else car(ll)
+ l = ll if isNull(ll) else car(ll)
return writeXML((entryElement(l),), True)
# Convert a list of values representing an ATOM feed to an ATOM feed
def writeATOMFeed(ll):
- l = ll if isNil(ll) else car(ll)
+ l = ll if isNull(ll) else car(ll)
lt = filter(selector((element, "'title")), l)
- t = '' if isNil(lt) else elementValue(car(lt))
+ t = '' if isNull(lt) else elementValue(car(lt))
li = filter(selector((element, "'id")), l)
- i = '' if isNil(li) else elementValue(car(li))
+ i = '' if isNull(li) else elementValue(car(li))
f = (element, "'feed", (attribute, "'xmlns", "http://www.w3.org/2005/Atom"),
(element, "'title", (attribute, "'type", "text"), t),
(element, "'id", i))
# Write ATOM entries
le = filter(selector((element, "'entry")), l)
- if isNil(le):
+ if isNull(le):
return writeXML((f,), True)
# 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)))):
+ if not isNull(le) and not isNull(car(le)) and isList(car(caddr(car(le)))):
fe = append(f, entriesElements(caddr(car(le))))
return writeXML((fe,), True)
diff --git a/sca-cpp/trunk/modules/wsgi/composite.py b/sca-cpp/trunk/modules/wsgi/composite.py
index 77f2ecdb59..fbec66dc33 100755
--- a/sca-cpp/trunk/modules/wsgi/composite.py
+++ b/sca-cpp/trunk/modules/wsgi/composite.py
@@ -59,7 +59,7 @@ def requestIfNoneMatch(e):
# Hash a list of strings into an MD5 signature
def md5update(md, s):
- if isNil(s):
+ if isNull(s):
return md.hexdigest()
md.update(car(s))
return md5update(md, cdr(s))
@@ -113,7 +113,7 @@ def fileresult(e, r, ct, f):
# Converts the args received in a POST to a list of key value pairs
def postArgs(a):
- if isNil(a):
+ if isNull(a):
return ((),)
l = car(a);
return cons(l, postArgs(cdr(a)))
@@ -188,16 +188,16 @@ def application(e, r):
return result(e, r, 200, (("Content-type", "application/json"),), writeJSON(()))
# Write content-type / content-list pair
- if isString(car(v)) and not isNil(cdr(v)) and isList(cadr(v)):
+ if isString(car(v)) and not isNull(cdr(v)) and isList(cadr(v)):
return result(e, r, 200, (("Content-type", car(v)),), cadr(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)):
+ if isList(car(ve)) and not isNull(car(ve)):
el = car(ve)
- if isSymbol(car(el)) and car(el) == element and not isNil(cdr(el)) and isSymbol(cadr(el)):
+ if isSymbol(car(el)) and car(el) == element and not isNull(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":
@@ -224,7 +224,7 @@ def application(e, r):
if contains(ct, "application/atom+xml"):
ae = elementsToValues(readATOMEntry(requestBody(e)))
v = comp("post", id, ae)
- if isNil(v):
+ if isNull(v):
return failure(e, r, 500)
return result(e, r, 201, (("Location", request_uri(e) + "/" + "/".join(v)),))
return failure(e, r, 500)
diff --git a/sca-cpp/trunk/modules/wsgi/elemutil.py b/sca-cpp/trunk/modules/wsgi/elemutil.py
index 00b76c5c6e..bb176e7ffe 100644
--- a/sca-cpp/trunk/modules/wsgi/elemutil.py
+++ b/sca-cpp/trunk/modules/wsgi/elemutil.py
@@ -25,13 +25,13 @@ atsign = "'@"
# Return true if a value is an element
def isElement(v):
- if not isList(v) or isNil(v) or v == None or car(v) != element:
+ if not isList(v) or isNull(v) or v == None or car(v) != element:
return False
return True
# Return true if a value is an attribute
def isAttribute(v):
- if not isList(v) or isNil(v) or v == None or car(v) != attribute:
+ if not isList(v) or isNull(v) or v == None or car(v) != attribute:
return False
return True
@@ -49,7 +49,7 @@ def elementName(l):
# Return true if an element has children
def elementHasChildren(l):
- return not isNil(cddr(l))
+ return not isNull(cddr(l))
# Return the children of an element
def elementChildren(l):
@@ -60,7 +60,7 @@ def elementHasValue(l):
r = reverse(l)
if isSymbol(car(r)):
return False
- if isList(car(r)) and not isNil(car(r)) and isSymbol(car(car(r))):
+ if isList(car(r)) and not isNull(car(r)) and isSymbol(car(car(r))):
return False
return True
@@ -72,7 +72,7 @@ def elementValue(l):
def elementToValueIsList(v):
if not isList(v):
return False
- return isNil(v) or not isSymbol(car(v))
+ return isNull(v) or not isSymbol(car(v))
def elementToValue(t):
if isTaggedList(t, attribute):
@@ -91,14 +91,14 @@ def elementToValue(t):
def elementToValueIsSymbol(v):
if not isList(v):
return False
- if (isNil(v)):
+ if (isNull(v)):
return False
if not isSymbol(car(v)):
return False
return True
def elementToValueGroupValues(v, l):
- if isNil(l) or not elementToValueIsSymbol(v) or not elementToValueIsSymbol(car(l)):
+ if isNull(l) or not elementToValueIsSymbol(v) or not elementToValueIsSymbol(car(l)):
return cons(v, l)
if car(car(l)) != car(v):
return cons(v, l)
@@ -109,20 +109,20 @@ def elementToValueGroupValues(v, l):
return elementToValueGroupValues(g, cdr(l))
def elementsToValues(e):
- if isNil(e):
+ if isNull(e):
return e
return elementToValueGroupValues(elementToValue(car(e)), elementsToValues(cdr(e)))
# Convert a value to an element
def valueToElement(t):
- if isList(t) and not isNil(t) and isSymbol(car(t)):
+ if isList(t) and not isNull(t) and isSymbol(car(t)):
n = car(t)
- v = () if isNil(cdr(t)) else cadr(t)
+ v = () if isNull(cdr(t)) else cadr(t)
if not isList(v):
if n[0:2] == atsign:
return (attribute, "'" + n[2:], v)
return (element, n, v)
- if isNil(v) or not isSymbol(car(v)):
+ if isNull(v) or not isSymbol(car(v)):
return cons(element, cons(n, (valuesToElements(v),)))
return cons(element, cons(n, valuesToElements(cdr(t))))
if not isList(t):
@@ -131,15 +131,15 @@ def valueToElement(t):
# Convert a list of values to a list of elements
def valuesToElements(l):
- if isNil(l):
+ if isNull(l):
return l
return cons(valueToElement(car(l)), valuesToElements(cdr(l)))
# Return a selector lambda function which can be used to filter elements
def evalSelect(s, v):
- if isNil(s):
+ if isNull(s):
return True
- if isNil(v):
+ if isNull(v):
return False
if car(s) != car(v):
return False
@@ -151,7 +151,7 @@ def selector(s):
# Return the value of the attribute with the given name
def namedAttributeValue(name, l):
f = filter(lambda v: isAttribute(v) and attributeName(v) == name, l)
- if isNil(f):
+ if isNull(f):
return None
return caddr(car(f))
@@ -162,7 +162,7 @@ def namedElementChildren(name, l):
# Return the child element with the given name
def namedElementChild(name, l):
f = namedElementChildren(name, l)
- if isNil(f):
+ if isNull(f):
return None
return car(f)
diff --git a/sca-cpp/trunk/modules/wsgi/jsonutil.py b/sca-cpp/trunk/modules/wsgi/jsonutil.py
index 849b44405b..f284fd1a89 100644
--- a/sca-cpp/trunk/modules/wsgi/jsonutil.py
+++ b/sca-cpp/trunk/modules/wsgi/jsonutil.py
@@ -28,19 +28,19 @@ from elemutil import *
# Return true if a list represents a JS array
def isJSArray(l):
- if isNil(l):
+ if isNull(l):
return True
v = car(l)
if isSymbol(v):
return False
if isList(v):
- if not isNil(v) and isSymbol(car(v)):
+ if not isNull(v) and isSymbol(car(v)):
return False
return True
# Converts JSON properties to values
def jsPropertiesToValues(propertiesSoFar, o, i):
- if isNil(i):
+ if isNull(i):
return propertiesSoFar
p = car(i)
jsv = o[p]
@@ -69,7 +69,7 @@ def jsValToValue(jsv):
# Return true if a list of strings contains a JSON document
def isJSON(l):
- if isNil(l):
+ if isNull(l):
return False
s = car(l)[0:1]
return s == "[" or s == "{"
@@ -83,7 +83,7 @@ def readJSON(l):
# Convert a list of values to JSON array elements
def valuesToJSElements(a, l, i):
- if isNil(l):
+ if isNull(l):
return a
pv = valueToJSVal(car(l))
a[i] = pv
@@ -99,7 +99,7 @@ def valueToJSVal(v):
# Convert a list of values to JSON properties
def valuesToJSProperties(o, l):
- if isNil(l):
+ if isNull(l):
return o
token = car(l)
if isTaggedList(token, attribute):
diff --git a/sca-cpp/trunk/modules/wsgi/rssutil.py b/sca-cpp/trunk/modules/wsgi/rssutil.py
index 984d71b690..c1b326c82d 100644
--- a/sca-cpp/trunk/modules/wsgi/rssutil.py
+++ b/sca-cpp/trunk/modules/wsgi/rssutil.py
@@ -24,22 +24,22 @@ from xmlutil import *
# Convert a list of elements to a list of values representing an RSS entry
def entryElementsToValues(e):
lt = filter(selector((element, "'title")), e)
- t = "" if isNil(lt) else elementValue(car(lt))
+ t = "" if isNull(lt) else elementValue(car(lt))
li = filter(selector((element, "'link")), e)
- i = "" if isNil(li) else elementValue(car(li))
+ i = "" if isNull(li) else elementValue(car(li))
lc = filter(selector((element, "'description")), e)
return (t, i, elementValue(car(lc)))
# Convert a list of elements to a list of values representing RSS entries
def entriesElementsToValues(e):
- if isNil(e):
+ if isNull(e):
return e
return cons(entryElementsToValues(car(e)), entriesElementsToValues(cdr(e)))
# Convert a list of strings to a list of values representing an RSS entry
def readRSSEntry(l):
e = readXML(l)
- if isNil(e):
+ if isNull(e):
return ()
return entryElementsToValues(car(e))
@@ -57,19 +57,19 @@ def isRSSFeed(l):
# Convert a list of strings to a list of values representing an RSS feed
def readRSSFeed(l):
f = readXML(l)
- if isNil(f):
+ if isNull(f):
return ()
c = filter(selector((element, "'channel")), car(f))
t = filter(selector((element, "'title")), car(c))
i = filter(selector((element, "'link")), car(c))
e = filter(selector((element, "'item")), car(c))
- if isNil(e):
+ if isNull(e):
return (elementValue(car(t)), elementValue(car(i)))
return cons(elementValue(car(t)), cons(elementValue(car(i)), entriesElementsToValues(e)))
# Convert an RSS feed containing elements to an RSS feed containing values
def feedValuesLoop(e):
- if (isNil(e)):
+ if (isNull(e)):
return e
return cons(entryValue(car(e)), feedValuesLoop(cdr(e)))
@@ -85,7 +85,7 @@ def entryElement(l):
# Convert a list of values representing RSS entries to a list of elements
def entriesElements(l):
- if isNil(l):
+ if isNull(l):
return l
return cons(entryElement(car(l)), entriesElements(cdr(l)))
@@ -98,7 +98,7 @@ def writeRSSFeed(l):
c = ((element, "'title", car(l)),
(element, "'link", cadr(l)),
(element, "'description", car(l)))
- ce = c if isNil(cddr(l)) else append(c, entriesElements(cddr(l)))
+ ce = c if isNull(cddr(l)) else append(c, entriesElements(cddr(l)))
fe = (element, "'rss", (attribute, "'version", "2.0"), append((element, "'channel"), ce))
return writeXML((fe,), True)
@@ -108,7 +108,7 @@ def entryValuesToElements(v):
# Convert an RSS feed containing values to an RSS feed containing elements
def feedValuesToElementsLoop(v):
- if isNil(v):
+ if isNull(v):
return v
return cons(entryValuesToElements(car(v)), feedValuesToElementsLoop(cdr(v)))
diff --git a/sca-cpp/trunk/modules/wsgi/util.py b/sca-cpp/trunk/modules/wsgi/util.py
index f630455901..97931c0c09 100644
--- a/sca-cpp/trunk/modules/wsgi/util.py
+++ b/sca-cpp/trunk/modules/wsgi/util.py
@@ -57,9 +57,9 @@ def reverse(l):
r.reverse()
return tuple(r)
-def isNil(l):
+def isNull(l):
if isinstance(l, streampair):
- return l.isNil()
+ return l.isNull()
return l is None or l == ()
def isSymbol(v):
@@ -76,7 +76,7 @@ def isList(v):
return True
def isTaggedList(v, t):
- return isList(v) and not isNil(v) and car(v) == t
+ return isList(v) and not isNull(v) and car(v) == t
# Scheme-like streams
@@ -88,7 +88,7 @@ class streampair(object):
def __repr__(self):
return repr(self[0:len(self)])
- def isNil(self):
+ def isNull(self):
return self.cdr == ()
def __len__(self):
@@ -102,7 +102,7 @@ class streampair(object):
return self.cdr()[i - 1]
def __getslice__(self, i, j):
- if isNil(self):
+ if isNull(self):
return ()
if i > 0:
if j == maxint:
@@ -156,7 +156,7 @@ def curry(f, *args):
# Convert a path represented as a list of values to a string
def path(p):
- if isNil(p):
+ if isNull(p):
return ""
return "/" + car(p) + path(cdr(p))
diff --git a/sca-cpp/trunk/modules/wsgi/xmlutil.py b/sca-cpp/trunk/modules/wsgi/xmlutil.py
index 83b1cf2f92..bc1a1b376a 100644
--- a/sca-cpp/trunk/modules/wsgi/xmlutil.py
+++ b/sca-cpp/trunk/modules/wsgi/xmlutil.py
@@ -46,7 +46,7 @@ def readElements(l):
# Return true if a list of strings represents an XML document
def isXML(l):
- if isNil(l):
+ if isNull(l):
return False
if car(l)[0:5] != "<?xml":
return False
@@ -86,12 +86,12 @@ def readXML(l):
# Write a list of XML element and attribute tokens
def expandElementValues(n, l):
- if isNil(l):
+ if isNull(l):
return l
return cons(cons(element, cons(n, car(l))), expandElementValues(n, cdr(l)))
def writeList(l, xml):
- if isNil(l):
+ if isNull(l):
return xml
token = car(l)
if isTaggedList(token, attribute):