summaryrefslogtreecommitdiffstats
path: root/sca-cpp/trunk/modules
diff options
context:
space:
mode:
Diffstat (limited to 'sca-cpp/trunk/modules')
-rw-r--r--sca-cpp/trunk/modules/java/test/Client.java2
-rw-r--r--sca-cpp/trunk/modules/java/test/ClientImpl.java4
-rw-r--r--sca-cpp/trunk/modules/java/test/Server.java2
-rw-r--r--sca-cpp/trunk/modules/java/test/ServerImpl.java4
-rwxr-xr-xsca-cpp/trunk/modules/java/wiring-test4
-rw-r--r--sca-cpp/trunk/modules/python/client-test.py3
-rw-r--r--sca-cpp/trunk/modules/python/server-test.py3
-rwxr-xr-xsca-cpp/trunk/modules/python/wiring-test4
-rw-r--r--sca-cpp/trunk/modules/server/client-test.hpp16
-rw-r--r--sca-cpp/trunk/modules/server/client-test.scm4
-rwxr-xr-xsca-cpp/trunk/modules/server/httpd-test4
-rw-r--r--sca-cpp/trunk/modules/server/impl-test.cpp6
-rw-r--r--sca-cpp/trunk/modules/server/mod-eval.hpp62
-rw-r--r--sca-cpp/trunk/modules/server/server-test.scm6
-rwxr-xr-xsca-cpp/trunk/modules/server/wiring-test4
-rw-r--r--sca-cpp/trunk/modules/wsgi/atomutil.py2
-rw-r--r--sca-cpp/trunk/modules/wsgi/client-test.py3
-rwxr-xr-xsca-cpp/trunk/modules/wsgi/composite.py8
-rw-r--r--sca-cpp/trunk/modules/wsgi/httputil.py14
-rw-r--r--sca-cpp/trunk/modules/wsgi/server-test.py3
-rw-r--r--sca-cpp/trunk/modules/wsgi/util.py17
-rwxr-xr-xsca-cpp/trunk/modules/wsgi/wiring-test4
-rwxr-xr-xsca-cpp/trunk/modules/wsgi/wsgi-test4
23 files changed, 163 insertions, 20 deletions
diff --git a/sca-cpp/trunk/modules/java/test/Client.java b/sca-cpp/trunk/modules/java/test/Client.java
index c3bd875fcc..d2b942c860 100644
--- a/sca-cpp/trunk/modules/java/test/Client.java
+++ b/sca-cpp/trunk/modules/java/test/Client.java
@@ -29,6 +29,8 @@ public interface Client {
Boolean put(Iterable<String> id, Iterable<?> item);
+ Boolean patch(Iterable<String> id, Iterable<?> item);
+
Boolean delete(Iterable<String> id);
}
diff --git a/sca-cpp/trunk/modules/java/test/ClientImpl.java b/sca-cpp/trunk/modules/java/test/ClientImpl.java
index ade2ba302e..f1ca0ca033 100644
--- a/sca-cpp/trunk/modules/java/test/ClientImpl.java
+++ b/sca-cpp/trunk/modules/java/test/ClientImpl.java
@@ -37,6 +37,10 @@ public class ClientImpl {
return server.put(id, item);
}
+ public Boolean patch(Iterable<String> id, Iterable<?> item, Server server) {
+ return server.patch(id, item);
+ }
+
public Boolean delete(Iterable<String> id, Server server) {
return server.delete(id);
}
diff --git a/sca-cpp/trunk/modules/java/test/Server.java b/sca-cpp/trunk/modules/java/test/Server.java
index 3dfe3c84ef..0f16da48fb 100644
--- a/sca-cpp/trunk/modules/java/test/Server.java
+++ b/sca-cpp/trunk/modules/java/test/Server.java
@@ -29,6 +29,8 @@ public interface Server {
Boolean put(Iterable<String> id, Iterable<?> item);
+ Boolean patch(Iterable<String> id, Iterable<?> item);
+
Boolean delete(Iterable<String> id);
}
diff --git a/sca-cpp/trunk/modules/java/test/ServerImpl.java b/sca-cpp/trunk/modules/java/test/ServerImpl.java
index ee25cf7bf8..4499681f78 100644
--- a/sca-cpp/trunk/modules/java/test/ServerImpl.java
+++ b/sca-cpp/trunk/modules/java/test/ServerImpl.java
@@ -49,6 +49,10 @@ public class ServerImpl {
return true;
}
+ public Boolean patch(final Iterable<String> id, final Iterable<?> item) {
+ return true;
+ }
+
public Boolean delete(final Iterable<String> id) {
return true;
}
diff --git a/sca-cpp/trunk/modules/java/wiring-test b/sca-cpp/trunk/modules/java/wiring-test
index dd865c4c66..6f01ecb145 100755
--- a/sca-cpp/trunk/modules/java/wiring-test
+++ b/sca-cpp/trunk/modules/java/wiring-test
@@ -61,6 +61,10 @@ if [ "$rc" = "0" ]; then
rc=$?
fi
if [ "$rc" = "0" ]; then
+ $curl_prefix/bin/curl http://localhost:8090/client/111 -X PATCH -H "Content-type: application/atom+xml" --data @../server/htdocs/test/entry.xml 2>/dev/null
+ rc=$?
+fi
+if [ "$rc" = "0" ]; then
$curl_prefix/bin/curl http://localhost:8090/client/111 -X DELETE 2>/dev/null
rc=$?
fi
diff --git a/sca-cpp/trunk/modules/python/client-test.py b/sca-cpp/trunk/modules/python/client-test.py
index 3c7183e865..5d73515ca2 100644
--- a/sca-cpp/trunk/modules/python/client-test.py
+++ b/sca-cpp/trunk/modules/python/client-test.py
@@ -36,5 +36,8 @@ def post(collection, item, ref):
def put(id, item, ref):
return ref.put(id, item)
+def patch(id, item, ref):
+ return ref.patch(id, item)
+
def delete(id, ref):
return ref.delete(id)
diff --git a/sca-cpp/trunk/modules/python/server-test.py b/sca-cpp/trunk/modules/python/server-test.py
index da5d216da5..fe493f671a 100644
--- a/sca-cpp/trunk/modules/python/server-test.py
+++ b/sca-cpp/trunk/modules/python/server-test.py
@@ -38,5 +38,8 @@ def post(collection, item):
def put(id, item):
return True
+def patch(id, item):
+ return True
+
def delete(id):
return True
diff --git a/sca-cpp/trunk/modules/python/wiring-test b/sca-cpp/trunk/modules/python/wiring-test
index 899c3eb5a1..e7bb6c410d 100755
--- a/sca-cpp/trunk/modules/python/wiring-test
+++ b/sca-cpp/trunk/modules/python/wiring-test
@@ -60,6 +60,10 @@ if [ "$rc" = "0" ]; then
rc=$?
fi
if [ "$rc" = "0" ]; then
+ $curl_prefix/bin/curl http://localhost:8090/client/111 -X PATCH -H "Content-type: application/atom+xml" --data @../server/htdocs/test/entry.xml 2>/dev/null
+ rc=$?
+fi
+if [ "$rc" = "0" ]; then
$curl_prefix/bin/curl http://localhost:8090/client/111 -X DELETE 2>/dev/null
rc=$?
fi
diff --git a/sca-cpp/trunk/modules/server/client-test.hpp b/sca-cpp/trunk/modules/server/client-test.hpp
index dc9ca299ad..29da9e4798 100644
--- a/sca-cpp/trunk/modules/server/client-test.hpp
+++ b/sca-cpp/trunk/modules/server/client-test.hpp
@@ -294,6 +294,21 @@ const bool testPut() {
return true;
}
+const bool testPatch() {
+ const gc_scoped_pool pool;
+ const list<value> i = nilListValue + "content" + (nilListValue + "item"
+ + (nilListValue + "name" + string("Apple"))
+ + (nilListValue + "price" + string("$2.99")));
+ const list<value> a = nilListValue + (nilListValue + "entry"
+ + (nilListValue + "title" + string("item"))
+ + (nilListValue + "id" + string("cart-53d67a61-aa5e-4e5e-8401-39edeba8b83b"))
+ + i);
+ const http::CURLSession ch("", "", "", "", 0);
+ const value rc = content(http::patch(a, testURI + "/111", ch));
+ assert(rc == trueValue);
+ return true;
+}
+
const bool testDel() {
const gc_scoped_pool pool;
const http::CURLSession ch("", "", "", "", 0);
@@ -306,6 +321,7 @@ const bool testServer() {
tuscany::server::testGet();
tuscany::server::testPost();
tuscany::server::testPut();
+ tuscany::server::testPatch();
tuscany::server::testDel();
tuscany::server::testEval();
tuscany::server::testGetPerf();
diff --git a/sca-cpp/trunk/modules/server/client-test.scm b/sca-cpp/trunk/modules/server/client-test.scm
index 47b799d390..a4db7f1b26 100644
--- a/sca-cpp/trunk/modules/server/client-test.scm
+++ b/sca-cpp/trunk/modules/server/client-test.scm
@@ -33,6 +33,10 @@
(ref "put" id entry)
)
+(define (patch id entry ref)
+ (ref "patch" id entry)
+)
+
(define (delete id ref)
(ref "delete" id)
)
diff --git a/sca-cpp/trunk/modules/server/httpd-test b/sca-cpp/trunk/modules/server/httpd-test
index 195caa4562..ef30682171 100755
--- a/sca-cpp/trunk/modules/server/httpd-test
+++ b/sca-cpp/trunk/modules/server/httpd-test
@@ -60,6 +60,10 @@ if [ "$rc" = "0" ]; then
rc=$?
fi
if [ "$rc" = "0" ]; then
+ $curl_prefix/bin/curl http://localhost:8090/scheme/111 -X PATCH -H "Content-type: application/atom+xml" --data @htdocs/test/entry.xml 2>/dev/null
+ rc=$?
+fi
+if [ "$rc" = "0" ]; then
$curl_prefix/bin/curl http://localhost:8090/scheme/111 -X DELETE 2>/dev/null
rc=$?
fi
diff --git a/sca-cpp/trunk/modules/server/impl-test.cpp b/sca-cpp/trunk/modules/server/impl-test.cpp
index a9bd9ad585..0ad1302217 100644
--- a/sca-cpp/trunk/modules/server/impl-test.cpp
+++ b/sca-cpp/trunk/modules/server/impl-test.cpp
@@ -45,6 +45,10 @@ const failable<value> put(unused const list<value>& params) {
return trueValue;
}
+const failable<value> patch(unused const list<value>& params) {
+ return trueValue;
+}
+
const failable<value> del(unused const list<value>& params) {
return trueValue;
}
@@ -66,6 +70,8 @@ const tuscany::value apply(const tuscany::list<tuscany::value>& params) {
return tuscany::server::post(cdr(params));
if (func == "put")
return tuscany::server::put(cdr(params));
+ if (func == "patch")
+ return tuscany::server::patch(cdr(params));
if (func == "delete")
return tuscany::server::del(cdr(params));
if (func == "echo")
diff --git a/sca-cpp/trunk/modules/server/mod-eval.hpp b/sca-cpp/trunk/modules/server/mod-eval.hpp
index aa13584534..5a8a15bf43 100644
--- a/sca-cpp/trunk/modules/server/mod-eval.hpp
+++ b/sca-cpp/trunk/modules/server/mod-eval.hpp
@@ -206,7 +206,7 @@ public:
debug(impls, "modeval::implProxy::callImpl::impls");
// Lookup the component implementation
- const list<value> impl(assoctree<value>(cname, (list<value>)impls));
+ const list<value> impl(rbtreeAssoc<value>(cname, (list<value>)impls));
if (isNil(impl))
return mkfailure<value>(string("Couldn't find component implementation: ") + (string)cname);
@@ -573,7 +573,7 @@ const failable<list<value> > applyLifecycleExpr(const list<value>& impls, const
* arranged in trees of reference-name + reference-target pairs.
*/
const list<value> componentReferenceToTargetTree(const value& c) {
- return mklist<value>(scdl::name(c), mkbtree(sort(scdl::referenceToTargetAssoc(scdl::references(c)))));
+ return mklist<value>(scdl::name(c), mkbrbtree(sort(scdl::referenceToTargetAssoc(scdl::references(c)))));
}
const list<value> componentReferenceToTargetAssoc(const list<value>& c) {
@@ -634,13 +634,13 @@ const failable<Composite> confComponents(const string& contribPath, const string
const list<value> comps = content(fcomps);
debug(comps, "modeval::confComponents::comps");
- const list<value> refs = mkbtree(sort(componentReferenceToTargetAssoc(comps)));
+ const list<value> refs = mkbrbtree(sort(componentReferenceToTargetAssoc(comps)));
debug(flatten(refs), "modeval::confComponents::refs");
- const list<value> svcs = mkbtree(sort(uriToComponentAssoc(comps)));
+ const list<value> svcs = mkbrbtree(sort(uriToComponentAssoc(comps)));
debug(flatten(svcs), "modeval::confComponents::svcs");
- const list<value> cimpls = mkbtree(sort(componentToImplementationAssoc(comps,
+ const list<value> cimpls = mkbrbtree(sort(componentToImplementationAssoc(comps,
isNil(contributor)? length(vhost) != 0? contribPath + vhost + "/" : contribPath : contribPath,
impls, lifecycle, sslc, timeout)));
debug(flatten(cimpls), "modeval::confComponents::impls");
@@ -659,7 +659,7 @@ const failable<list<value> > startComponents(const list<value>& impls) {
const list<value> simpls = content(fsimpls);
debug(impls, "modeval::startComponents::simpls");
- return mkbtree(sort(simpls));
+ return mkbrbtree(sort(simpls));
}
/**
@@ -696,7 +696,7 @@ const failable<int> get(const list<value>& rpath, request_rec* const r, const lv
debug(r->uri, "modeval::get::uri");
// Inspect the query string
- const list<list<value> > args = httpd::unescapeArgs(httpd::queryArgs(r));
+ const list<value> args = httpd::unescapeArgs(httpd::queryArgs(r));
const list<value> ia = assoc(value("id"), args);
const list<value> ma = assoc(value("method"), args);
@@ -795,7 +795,7 @@ const failable<int> post(const list<value>& rpath, request_rec* const r, const l
const list<string> ls = httpd::read(r);
debug(ls, "modeval::post::input");
const value jsreq = content(json::readValue(ls));
- const list<list<value> > args = httpd::postArgs(jsreq);
+ const list<value> args = httpd::postArgs(jsreq);
// Extract the request id, method and params
const value id = cadr(assoc(value("id"), args));
@@ -878,6 +878,34 @@ const failable<int> put(const list<value>& rpath, request_rec* const r, const lv
}
/**
+ * Handle an HTTP PATCH.
+ */
+const failable<int> patch(const list<value>& rpath, request_rec* const r, const lvvlambda& impl) {
+ debug(r->uri, "modeval::put::patch");
+
+ // Read the ATOM entry
+ const int rc = httpd::setupReadPolicy(r);
+ if(rc != OK)
+ return rc;
+ const list<string> ls = httpd::read(r);
+ debug(ls, "modeval::patch::input");
+ const value aval = elementsToValues(content(atom::isATOMEntry(ls)? atom::readATOMEntry(ls) : atom::readATOMFeed(ls)));
+
+ // Evaluate the PATCH expression and update the corresponding resource
+ const failable<value> val = failableResult(impl(cons<value>("patch", mklist<value>(cddr(rpath), aval))));
+ if (!hasContent(val))
+ return mkfailure<int>(val);
+
+ // Report HTTP status
+ const value rval = content(val);
+ if (isNil(rval) || rval == falseValue)
+ return HTTP_NOT_FOUND;
+ if (isNumber(rval))
+ return (int)rval;
+ return OK;
+}
+
+/**
* Handle an HTTP DELETE.
*/
const failable<int> del(const list<value>& rpath, request_rec* const r, const lvvlambda& impl) {
@@ -928,7 +956,7 @@ int translateComponent(request_rec* const r, const list<value>& rpath, const lis
// Find the requested component
if (isNil(cdr(rpath)))
return HTTP_NOT_FOUND;
- const list<value> impl(assoctree(cadr(rpath), impls));
+ const list<value> impl(rbtreeAssoc(cadr(rpath), impls));
if (isNil(impl))
return HTTP_NOT_FOUND;
debug(impl, "modeval::translateComponent::impl");
@@ -947,13 +975,13 @@ int translateReference(request_rec* const r, const list<value>& rpath, const lis
// Find the requested component
if (isNil(cdr(rpath)))
return HTTP_NOT_FOUND;
- const list<value> comp(assoctree(cadr(rpath), refs));
+ const list<value> comp(rbtreeAssoc(cadr(rpath), refs));
if (isNil(comp))
return HTTP_NOT_FOUND;
debug(comp, "modeval::translateReference::comp");
// Find the requested reference and target configuration
- const list<value> ref(assoctree<value>(caddr(rpath), cadr(comp)));
+ const list<value> ref(rbtreeAssoc<value>(caddr(rpath), cadr(comp)));
if (isNil(ref))
return HTTP_NOT_FOUND;
debug(ref, "modeval::translateReference::ref");
@@ -1087,7 +1115,7 @@ const int translateRequest(request_rec* const r, const list<value>& rpath, const
* Translate a request.
*/
int translate(request_rec *r) {
- if(r->method_number != M_GET && r->method_number != M_POST && r->method_number != M_PUT && r->method_number != M_DELETE)
+ if(r->method_number != M_GET && r->method_number != M_POST && r->method_number != M_PUT && r->method_number != M_PATCH && r->method_number != M_DELETE)
return DECLINED;
const gc_scoped_pool sp(r->pool);
@@ -1151,7 +1179,7 @@ const int handleRequest(const list<value>& rpath, request_rec* const r, const li
debug(rpath, "modeval::handleRequest::path");
// Get the component implementation lambda
- const list<value> impl(assoctree<value>(cadr(rpath), impls));
+ const list<value> impl(rbtreeAssoc<value>(cadr(rpath), impls));
if (isNil(impl)) {
mkfailure<int>(string("Couldn't find component implementation: ") + (string)cadr(rpath));
return HTTP_NOT_FOUND;
@@ -1167,6 +1195,8 @@ const int handleRequest(const list<value>& rpath, request_rec* const r, const li
return httpd::reportStatus(post(rpath, r, l));
if(r->method_number == M_PUT)
return httpd::reportStatus(put(rpath, r, l));
+ if(r->method_number == M_PATCH)
+ return httpd::reportStatus(patch(rpath, r, l));
if(r->method_number == M_DELETE)
return httpd::reportStatus(del(rpath, r, l));
return HTTP_NOT_IMPLEMENTED;
@@ -1219,7 +1249,7 @@ int handler(request_rec* r) {
const list<value> simpls = content(fsimpls);
// Merge the components in the virtual host with the components in the main host
- reqc.impls = mkbtree(sort(append(flatten((const list<value>)sc.compos.impls), flatten(simpls))));
+ reqc.impls = mkbrbtree(sort(append(flatten((const list<value>)sc.compos.impls), flatten(simpls))));
// Handle the request against the running components
const int rc = handleRequest(reqc.rpath, r, reqc.impls);
@@ -1418,7 +1448,7 @@ void childInit(apr_pool_t* p, server_rec* s) {
// Get the vhost contributor component implementation lambda
if (length(sc.vhostc.contributorName) != 0) {
- const list<value> impl(assoctree<value>((string)sc.vhostc.contributorName, (const list<value>)sc.compos.impls));
+ const list<value> impl(rbtreeAssoc<value>((string)sc.vhostc.contributorName, (const list<value>)sc.compos.impls));
if (isNil(impl)) {
mkfailure<int>(string("Couldn't find contributor component implementation: ") + sc.vhostc.contributorName);
failureExitChild();
@@ -1428,7 +1458,7 @@ void childInit(apr_pool_t* p, server_rec* s) {
// Get the vhost authenticator component implementation lambda
if (length(sc.vhostc.authenticatorName) != 0) {
- const list<value> impl(assoctree<value>((string)sc.vhostc.authenticatorName, (const list<value>)sc.compos.impls));
+ const list<value> impl(rbtreeAssoc<value>((string)sc.vhostc.authenticatorName, (const list<value>)sc.compos.impls));
if (isNil(impl)) {
mkfailure<int>(string("Couldn't find authenticator component implementation: ") + sc.vhostc.authenticatorName);
failureExitChild();
diff --git a/sca-cpp/trunk/modules/server/server-test.scm b/sca-cpp/trunk/modules/server/server-test.scm
index 4bbff6e5c2..b9ed6d584c 100644
--- a/sca-cpp/trunk/modules/server/server-test.scm
+++ b/sca-cpp/trunk/modules/server/server-test.scm
@@ -22,7 +22,7 @@
; ATOMPub test case
(define (get id)
- (if (nul id)
+ (if (null? id)
'((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))))
@@ -39,6 +39,10 @@
true
)
+(define (patch id item)
+ true
+)
+
(define (delete id)
true
)
diff --git a/sca-cpp/trunk/modules/server/wiring-test b/sca-cpp/trunk/modules/server/wiring-test
index 7e1aea22b1..a00255e332 100755
--- a/sca-cpp/trunk/modules/server/wiring-test
+++ b/sca-cpp/trunk/modules/server/wiring-test
@@ -60,6 +60,10 @@ if [ "$rc" = "0" ]; then
rc=$?
fi
if [ "$rc" = "0" ]; then
+ $curl_prefix/bin/curl http://localhost:8090/client/111 -X PATCH -H "Content-type: application/atom+xml" --data @htdocs/test/entry.xml 2>/dev/null
+ rc=$?
+fi
+if [ "$rc" = "0" ]; then
$curl_prefix/bin/curl http://localhost:8090/client/111 -X DELETE 2>/dev/null
rc=$?
fi
diff --git a/sca-cpp/trunk/modules/wsgi/atomutil.py b/sca-cpp/trunk/modules/wsgi/atomutil.py
index ad6425f062..4b67ef216e 100644
--- a/sca-cpp/trunk/modules/wsgi/atomutil.py
+++ b/sca-cpp/trunk/modules/wsgi/atomutil.py
@@ -29,7 +29,7 @@ def entryElementValues(e):
i = "" if isNil(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 ((element, "'content", elementValue(car(lc))),))
+ () if isNil(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):
diff --git a/sca-cpp/trunk/modules/wsgi/client-test.py b/sca-cpp/trunk/modules/wsgi/client-test.py
index 867222e792..5c67269885 100644
--- a/sca-cpp/trunk/modules/wsgi/client-test.py
+++ b/sca-cpp/trunk/modules/wsgi/client-test.py
@@ -36,5 +36,8 @@ def post(collection, item, ref):
def put(id, item, ref):
return ref.put(id, item)
+def patch(id, item, ref):
+ return ref.patch(id, item)
+
def delete(id, ref):
return ref.delete(id)
diff --git a/sca-cpp/trunk/modules/wsgi/composite.py b/sca-cpp/trunk/modules/wsgi/composite.py
index baea7aa053..77f2ecdb59 100755
--- a/sca-cpp/trunk/modules/wsgi/composite.py
+++ b/sca-cpp/trunk/modules/wsgi/composite.py
@@ -237,6 +237,14 @@ def application(e, r):
return failure(e, r, 404)
return result(e, r, 200)
+ if m == "PATCH":
+ # Handle an ATOM entry PATCH
+ ae = elementsToValues(readATOMEntry(requestBody(e)))
+ v = comp("patch", id, ae)
+ if v == False:
+ return failure(e, r, 404)
+ return result(e, r, 200)
+
if m == "DELETE":
v = comp("delete", id)
if v == False:
diff --git a/sca-cpp/trunk/modules/wsgi/httputil.py b/sca-cpp/trunk/modules/wsgi/httputil.py
index 842460cc6a..f98418d0bc 100644
--- a/sca-cpp/trunk/modules/wsgi/httputil.py
+++ b/sca-cpp/trunk/modules/wsgi/httputil.py
@@ -124,6 +124,20 @@ class client:
return None
return True
+ # handle a PATCH request
+ if func == "patch":
+ u = requesturi(self.url, car(args))
+ print >> stderr, "Client PATCH request", u
+ req = StringIO()
+ writeStrings(atomutil.writeATOMEntry(atomutil.entryValuesToElements(cadr(args))), req)
+ headers["Content-type"] = "application/atom+xml"
+ c.request("PATCH", u, req.getvalue(), headers)
+ res = c.getresponse()
+ print >> stderr, "Client status", res.status
+ if res.status != 200:
+ return None
+ return True
+
# handle a DELETE request
if func == "delete":
u = requesturi(self.url, car(args))
diff --git a/sca-cpp/trunk/modules/wsgi/server-test.py b/sca-cpp/trunk/modules/wsgi/server-test.py
index 610ec05075..b2bc0efe98 100644
--- a/sca-cpp/trunk/modules/wsgi/server-test.py
+++ b/sca-cpp/trunk/modules/wsgi/server-test.py
@@ -41,5 +41,8 @@ def post(collection, item):
def put(id, item):
return True
+def patch(id, item):
+ return True
+
def delete(id):
return True
diff --git a/sca-cpp/trunk/modules/wsgi/util.py b/sca-cpp/trunk/modules/wsgi/util.py
index 24467fd2cb..f630455901 100644
--- a/sca-cpp/trunk/modules/wsgi/util.py
+++ b/sca-cpp/trunk/modules/wsgi/util.py
@@ -60,7 +60,7 @@ def reverse(l):
def isNil(l):
if isinstance(l, streampair):
return l.isNil()
- return l == ()
+ return l is None or l == ()
def isSymbol(v):
return isinstance(v, basestring) and v[0:1] == "'"
@@ -132,11 +132,24 @@ def cons_stream(car, cdr):
def assoc(k, l):
if l == ():
return None
-
if k == car(car(l)):
return car(l)
return assoc(k, cdr(l))
+def delAssoc(k, l):
+ if l == ():
+ return ()
+ if k == car(car(l)):
+ return delAssoc(k, cdr(l))
+ return cons(car(l), delAssoc(k, cdr(l)))
+
+def putAssoc(a, l):
+ if l == ():
+ return (a,)
+ if car(a) == car(car(l)):
+ return cons(a, cdr(l))
+ return cons(car(l), putAssoc(a, cdr(l)))
+
# Currying / partial function application
def curry(f, *args):
return lambda *a: f(*(args + a))
diff --git a/sca-cpp/trunk/modules/wsgi/wiring-test b/sca-cpp/trunk/modules/wsgi/wiring-test
index cbecc201e8..4a8d15a5bd 100755
--- a/sca-cpp/trunk/modules/wsgi/wiring-test
+++ b/sca-cpp/trunk/modules/wsgi/wiring-test
@@ -56,6 +56,10 @@ if [ "$rc" = "0" ]; then
rc=$?
fi
if [ "$rc" = "0" ]; then
+ $curl_prefix/bin/curl $uri/client/111 -X PATCH -H "Content-type: application/atom+xml" --data @htdocs/test/entry.xml 2>/dev/null
+ rc=$?
+fi
+if [ "$rc" = "0" ]; then
$curl_prefix/bin/curl $uri/client/111 -X DELETE 2>/dev/null
rc=$?
fi
diff --git a/sca-cpp/trunk/modules/wsgi/wsgi-test b/sca-cpp/trunk/modules/wsgi/wsgi-test
index f8334b33ad..8deeb4d0ba 100755
--- a/sca-cpp/trunk/modules/wsgi/wsgi-test
+++ b/sca-cpp/trunk/modules/wsgi/wsgi-test
@@ -52,6 +52,10 @@ if [ "$rc" = "0" ]; then
rc=$?
fi
if [ "$rc" = "0" ]; then
+ $curl_prefix/bin/curl http://localhost:8090/wsgi/111 -X PATCH -H "Content-type: application/atom+xml" --data @htdocs/test/entry.xml 2>/dev/null
+ rc=$?
+fi
+if [ "$rc" = "0" ]; then
$curl_prefix/bin/curl http://localhost:8090/wsgi/111 -X DELETE 2>/dev/null
rc=$?
fi