tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jsdelf...@apache.org
Subject svn commit: r917286 - in /tuscany/sca-cpp/trunk: ./ etc/ modules/ modules/python/ modules/wsgi/
Date Sun, 28 Feb 2010 20:01:44 GMT
Author: jsdelfino
Date: Sun Feb 28 20:01:44 2010
New Revision: 917286

URL: http://svn.apache.org/viewvc?rev=917286&view=rev
Log:
Strawman WSGI integration, allowing Python components to run in a Python WSGI server.

Added:
    tuscany/sca-cpp/trunk/modules/wsgi/
    tuscany/sca-cpp/trunk/modules/wsgi/Makefile.am
      - copied, changed from r917285, tuscany/sca-cpp/trunk/modules/Makefile.am
    tuscany/sca-cpp/trunk/modules/wsgi/app.yaml
      - copied, changed from r917285, tuscany/sca-cpp/trunk/modules/Makefile.am
    tuscany/sca-cpp/trunk/modules/wsgi/client-test.cpp
    tuscany/sca-cpp/trunk/modules/wsgi/client-test.py
      - copied, changed from r917285, tuscany/sca-cpp/trunk/modules/Makefile.am
    tuscany/sca-cpp/trunk/modules/wsgi/composite.py   (with props)
    tuscany/sca-cpp/trunk/modules/wsgi/domain-test.composite
    tuscany/sca-cpp/trunk/modules/wsgi/runtime.py
      - copied, changed from r917285, tuscany/sca-cpp/trunk/modules/Makefile.am
    tuscany/sca-cpp/trunk/modules/wsgi/scdl.py
    tuscany/sca-cpp/trunk/modules/wsgi/server-test   (contents, props changed)
      - copied, changed from r917285, tuscany/sca-cpp/trunk/modules/Makefile.am
    tuscany/sca-cpp/trunk/modules/wsgi/server-test.py
    tuscany/sca-cpp/trunk/modules/wsgi/util.py
    tuscany/sca-cpp/trunk/modules/wsgi/wiring-test   (with props)
    tuscany/sca-cpp/trunk/modules/wsgi/wsgi-start   (contents, props changed)
      - copied, changed from r917285, tuscany/sca-cpp/trunk/modules/Makefile.am
    tuscany/sca-cpp/trunk/modules/wsgi/wsgi-stop   (contents, props changed)
      - copied, changed from r917285, tuscany/sca-cpp/trunk/modules/Makefile.am
Modified:
    tuscany/sca-cpp/trunk/configure.ac
    tuscany/sca-cpp/trunk/etc/git-exclude
    tuscany/sca-cpp/trunk/modules/Makefile.am
    tuscany/sca-cpp/trunk/modules/python/Makefile.am

Modified: tuscany/sca-cpp/trunk/configure.ac
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/configure.ac?rev=917286&r1=917285&r2=917286&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/configure.ac (original)
+++ tuscany/sca-cpp/trunk/configure.ac Sun Feb 28 20:01:44 2010
@@ -277,14 +277,17 @@
 # Configure path to Python 2.6 includes and lib.
 AC_MSG_CHECKING([for python])
 AC_ARG_WITH([python], [AC_HELP_STRING([--with-python=PATH], [path to installed Python 2.6
[default=/usr]])], [
+  PYTHON_PREFIX="${withval}"
   PYTHON_INCLUDE="${withval}/include"
   PYTHON_LIB="${withval}/lib"
   AC_MSG_RESULT("${withval}")
 ], [
+  PYTHON_PREFIX="/usr"
   PYTHON_INCLUDE="/usr/include"
   PYTHON_LIB="/usr/lib"
   AC_MSG_RESULT(/usr)
 ])
+AC_SUBST(PYTHON_PREFIX)
 AC_SUBST(PYTHON_INCLUDE)
 AC_SUBST(PYTHON_LIB)
 
@@ -523,6 +526,7 @@
                  modules/python/Makefile
                  modules/java/Makefile
                  modules/server/Makefile
+                 modules/wsgi/Makefile
                  components/Makefile
                  components/cache/Makefile
                  components/log/Makefile

Modified: tuscany/sca-cpp/trunk/etc/git-exclude
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/etc/git-exclude?rev=917286&r1=917285&r2=917286&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/etc/git-exclude (original)
+++ tuscany/sca-cpp/trunk/etc/git-exclude Sun Feb 28 20:01:44 2010
@@ -21,6 +21,7 @@
 .deployables/
 .wtpmodules/
 .pydevproject
+.buildpath
 .svn/
 .cvs/
 .dotest/

Modified: tuscany/sca-cpp/trunk/modules/Makefile.am
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/modules/Makefile.am?rev=917286&r1=917285&r2=917286&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/modules/Makefile.am (original)
+++ tuscany/sca-cpp/trunk/modules/Makefile.am Sun Feb 28 20:01:44 2010
@@ -15,7 +15,7 @@
 #  specific language governing permissions and limitations
 #  under the License.
 
-SUBDIRS = scheme atom json scdl http server python java
+SUBDIRS = scheme atom json scdl http server python wsgi java
 
 includedir = $(prefix)/include/modules
 nobase_include_HEADERS = */*.hpp

Modified: tuscany/sca-cpp/trunk/modules/python/Makefile.am
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/modules/python/Makefile.am?rev=917286&r1=917285&r2=917286&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/modules/python/Makefile.am (original)
+++ tuscany/sca-cpp/trunk/modules/python/Makefile.am Sun Feb 28 20:01:44 2010
@@ -25,9 +25,13 @@
 lib_LTLIBRARIES = libmod_tuscany_python.la
 
 nobase_data_DATA = *.xsd
+data_DATA = python.prefix
 
 INCLUDES = -I${PYTHON_INCLUDE}
 
+python.prefix: $(top_builddir)/config.status
+	echo ${PYTHON_PREFIX} >python.prefix
+
 libmod_tuscany_python_la_SOURCES = mod-python.cpp
 libmod_tuscany_python_la_LDFLAGS = -lxml2 -lcurl -lmozjs -L${PYTHON_LIB} -R${PYTHON_LIB}
-lpython2.6
 

Copied: tuscany/sca-cpp/trunk/modules/wsgi/Makefile.am (from r917285, tuscany/sca-cpp/trunk/modules/Makefile.am)
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/modules/wsgi/Makefile.am?p2=tuscany/sca-cpp/trunk/modules/wsgi/Makefile.am&p1=tuscany/sca-cpp/trunk/modules/Makefile.am&r1=917285&r2=917286&rev=917286&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/modules/Makefile.am (original)
+++ tuscany/sca-cpp/trunk/modules/wsgi/Makefile.am Sun Feb 28 20:01:44 2010
@@ -15,8 +15,19 @@
 #  specific language governing permissions and limitations
 #  under the License.
 
-SUBDIRS = scheme atom json scdl http server python java
+datadir=$(prefix)/modules/wsgi
 
-includedir = $(prefix)/include/modules
-nobase_include_HEADERS = */*.hpp
+if WANT_PYTHON
 
+noinst_PROGRAMS = client-test
+
+nobase_data_DATA = *.yaml
+
+INCLUDES = -I${PYTHON_INCLUDE}
+
+client_test_SOURCES = client-test.cpp
+client_test_LDFLAGS = -lxml2 -lcurl -lmozjs
+
+TESTS = server-test
+
+endif

Copied: tuscany/sca-cpp/trunk/modules/wsgi/app.yaml (from r917285, tuscany/sca-cpp/trunk/modules/Makefile.am)
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/modules/wsgi/app.yaml?p2=tuscany/sca-cpp/trunk/modules/wsgi/app.yaml&p1=tuscany/sca-cpp/trunk/modules/Makefile.am&r1=917285&r2=917286&rev=917286&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/modules/Makefile.am (original)
+++ tuscany/sca-cpp/trunk/modules/wsgi/app.yaml Sun Feb 28 20:01:44 2010
@@ -1,22 +1,25 @@
-#  Licensed to the Apache Software Foundation (ASF) under one
-#  or more contributor license agreements.  See the NOTICE file
-#  distributed with this work for additional information
-#  regarding copyright ownership.  The ASF licenses this file
-#  to you under the Apache License, Version 2.0 (the
-#  "License"); you may not use this file except in compliance
-#  with the License.  You may obtain a copy of the License at
-#  
-#    http://www.apache.org/licenses/LICENSE-2.0
-#    
-#  Unless required by applicable law or agreed to in writing,
-#  software distributed under the License is distributed on an
-#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-#  KIND, either express or implied.  See the License for the
-#  specific language governing permissions and limitations
-#  under the License.
-
-SUBDIRS = scheme atom json scdl http server python java
-
-includedir = $(prefix)/include/modules
-nobase_include_HEADERS = */*.hpp
-
+#  Licensed to the Apache Software Foundation (ASF) under one
+#  or more contributor license agreements.  See the NOTICE file
+#  distributed with this work for additional information
+#  regarding copyright ownership.  The ASF licenses this file
+#  to you under the Apache License, Version 2.0 (the
+#  "License"); you may not use this file except in compliance
+#  with the License.  You may obtain a copy of the License at
+#  
+#    http://www.apache.org/licenses/LICENSE-2.0
+#    
+#  Unless required by applicable law or agreed to in writing,
+#  software distributed under the License is distributed on an
+#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+#  KIND, either express or implied.  See the License for the
+#  specific language governing permissions and limitations
+#  under the License.
+
+application: wsgi-app
+version: 1
+runtime: python
+api_version: 1
+
+handlers:
+- url: /.*
+  script: composite.py

Added: tuscany/sca-cpp/trunk/modules/wsgi/client-test.cpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/modules/wsgi/client-test.cpp?rev=917286&view=auto
==============================================================================
--- tuscany/sca-cpp/trunk/modules/wsgi/client-test.cpp (added)
+++ tuscany/sca-cpp/trunk/modules/wsgi/client-test.cpp Sun Feb 28 20:01:44 2010
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/* $Rev$ $Date$ */
+
+/**
+ * Test HTTP client functions.
+ */
+
+#include "stream.hpp"
+#include "string.hpp"
+#include "../server/client-test.hpp"
+
+namespace tuscany {
+namespace server {
+
+string testURI = "http://localhost:8090/wsgi";
+
+}
+}
+
+int main() {
+    tuscany::cout << "Testing..." << tuscany::endl;
+
+    tuscany::server::testServer();
+
+    tuscany::cout << "OK" << tuscany::endl;
+
+    return 0;
+}

Copied: tuscany/sca-cpp/trunk/modules/wsgi/client-test.py (from r917285, tuscany/sca-cpp/trunk/modules/Makefile.am)
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/modules/wsgi/client-test.py?p2=tuscany/sca-cpp/trunk/modules/wsgi/client-test.py&p1=tuscany/sca-cpp/trunk/modules/Makefile.am&r1=917285&r2=917286&rev=917286&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/modules/Makefile.am (original)
+++ tuscany/sca-cpp/trunk/modules/wsgi/client-test.py Sun Feb 28 20:01:44 2010
@@ -15,8 +15,21 @@
 #  specific language governing permissions and limitations
 #  under the License.
 
-SUBDIRS = scheme atom json scdl http server python java
+# JSON-RPC test case
 
-includedir = $(prefix)/include/modules
-nobase_include_HEADERS = */*.hpp
+def echo(x, ref):
+    return ref("echo", x)
 
+# ATOMPub test case
+
+def get(id, ref):
+    return ref("get", id)
+
+def post(collection, item, ref):
+    return ref("post", collection, item)
+
+def put(id, item, ref):
+    return ref("put", id, item)
+
+def delete(id, ref):
+    return ref("delete", id)

Added: tuscany/sca-cpp/trunk/modules/wsgi/composite.py
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/modules/wsgi/composite.py?rev=917286&view=auto
==============================================================================
--- tuscany/sca-cpp/trunk/modules/wsgi/composite.py (added)
+++ tuscany/sca-cpp/trunk/modules/wsgi/composite.py Sun Feb 28 20:01:44 2010
@@ -0,0 +1,103 @@
+#!/usr/bin/python
+#  Licensed to the Apache Software Foundation (ASF) under one
+#  or more contributor license agreements.  See the NOTICE file
+#  distributed with this work for additional information
+#  regarding copyright ownership.  The ASF licenses this file
+#  to you under the Apache License, Version 2.0 (the
+#  "License"); you may not use this file except in compliance
+#  with the License.  You may obtain a copy of the License at
+#  
+#    http://www.apache.org/licenses/LICENSE-2.0
+#    
+#  Unless required by applicable law or agreed to in writing,
+#  software distributed under the License is distributed on an
+#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+#  KIND, either express or implied.  See the License for the
+#  specific language governing permissions and limitations
+#  under the License.
+
+# Composite deployment and integration with WSGI
+
+from wsgiref.simple_server import make_server
+from wsgiref.handlers import CGIHandler
+from os import environ
+from sys import stderr, argv
+from util import *
+from scdl import *
+
+def requestPath(e):
+    return e.get("PATH_INFO", "")
+
+def requestMethod(e):
+    return e.get("REQUEST_METHOD", "")
+
+def contentType(ct):
+    if ct == None:
+        return []
+    return [("Content-type", ct)]
+
+def status(st):
+    if st == 200:
+        return "200 OK"
+    if st == 404:
+        return "404 Not Found"
+    if st == 201:
+        return "201 Created"
+    return "500 Internal Server Error"
+
+def result(r, st, ct = None, b = ()):
+    r(status(st), contentType(ct))
+    return b
+
+# WSGI application function
+def application(e, r):
+
+    # Read the deployed composite
+    comps = components(parse("domain-test.composite"))
+    print >> stderr, comps
+    
+    # Find the requested component
+    path = tokens(requestPath(e))
+    uc = uriToComponent(path, comps)
+    uri = car(uc)
+    if uri == None:
+        return result(r, 404)
+    comp =  cadr(uc)
+    mod = __import__(cadr(comp))
+    
+    # Call the requested component function
+    id = path[len(uri):]
+    print >> stderr, id
+    m = requestMethod(e)
+    if (m == "GET"):
+        v = mod.get(id)
+        print >> stderr, v
+        
+        # write returned content-type / content pair
+        if not isinstance(cadr(v), basestring):
+            return result(r, 200, car(v), cadr(v))
+        
+        # TODO write an ATOM feed or entry
+        if nil(id):
+            return result(r, 200, "application/atom+xml;type=feed", ("Atom feed"))
+        return result(r, 200, "application/atom+xml;type=entry", ("Atom entry"))
+
+    if m == "DELETE":
+        v = mod.delete(id)
+        if v == False:
+            return result(r, 404)
+        return result(r, 200)
+    
+    # TODO implement POST and PUT methods
+    return result(r, 500)
+
+def serverType(e):
+    return e.get("SERVER_SOFTWARE", "")
+
+# Run the WSGI application
+if __name__ == "__main__":
+    st = serverType(environ)
+    if st == "":
+        make_server("", int(argv[1]), application).serve_forever()
+    else:
+        CGIHandler().run(application)

Propchange: tuscany/sca-cpp/trunk/modules/wsgi/composite.py
------------------------------------------------------------------------------
    svn:executable = *

Added: tuscany/sca-cpp/trunk/modules/wsgi/domain-test.composite
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/modules/wsgi/domain-test.composite?rev=917286&view=auto
==============================================================================
--- tuscany/sca-cpp/trunk/modules/wsgi/domain-test.composite (added)
+++ tuscany/sca-cpp/trunk/modules/wsgi/domain-test.composite Sun Feb 28 20:01:44 2010
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+-->
+<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+  xmlns:t="http://tuscany.apache.org/xmlns/sca/1.1"
+  targetNamespace="http://domain/test"
+  name="domain-test">
+        
+    <component name="wsgi-test">
+        <t:implementation.python script="server-test.py"/>
+        <service name="test">
+            <t:binding.http uri="wsgi"/>
+        </service>
+    </component>     
+
+    <component name="client-test">
+        <t:implementation.python script="client-test.py"/>
+        <service name="client">
+            <t:binding.http uri="client"/>
+        </service>
+        <reference name="ref" target="wsgi-test">
+            <t:binding.http/>
+        </reference>
+    </component>
+
+</composite>

Copied: tuscany/sca-cpp/trunk/modules/wsgi/runtime.py (from r917285, tuscany/sca-cpp/trunk/modules/Makefile.am)
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/modules/wsgi/runtime.py?p2=tuscany/sca-cpp/trunk/modules/wsgi/runtime.py&p1=tuscany/sca-cpp/trunk/modules/Makefile.am&r1=917285&r2=917286&rev=917286&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/modules/Makefile.am (original)
+++ tuscany/sca-cpp/trunk/modules/wsgi/runtime.py Sun Feb 28 20:01:44 2010
@@ -15,8 +15,16 @@
 #  specific language governing permissions and limitations
 #  under the License.
 
-SUBDIRS = scheme atom json scdl http server python java
+# Component invocation functions
 
-includedir = $(prefix)/include/modules
-nobase_include_HEADERS = */*.hpp
+from util import *
 
+def apply(impl, refs, func, params):
+    m = __import__(impl)
+    f = m.__getattribute__(func)
+    p = refs + params
+    return f(*p)
+
+def refapply(comps, target):
+    return comps["target"]
+    

Added: tuscany/sca-cpp/trunk/modules/wsgi/scdl.py
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/modules/wsgi/scdl.py?rev=917286&view=auto
==============================================================================
--- tuscany/sca-cpp/trunk/modules/wsgi/scdl.py (added)
+++ tuscany/sca-cpp/trunk/modules/wsgi/scdl.py Sun Feb 28 20:01:44 2010
@@ -0,0 +1,89 @@
+#  Licensed to the Apache Software Foundation (ASF) under one
+#  or more contributor license agreements.  See the NOTICE file
+#  distributed with this work for additional information
+#  regarding copyright ownership.  The ASF licenses this file
+#  to you under the Apache License, Version 2.0 (the
+#  "License"); you may not use this file except in compliance
+#  with the License.  You may obtain a copy of the License at
+#  
+#    http://www.apache.org/licenses/LICENSE-2.0
+#    
+#  Unless required by applicable law or agreed to in writing,
+#  software distributed under the License is distributed on an
+#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+#  KIND, either express or implied.  See the License for the
+#  specific language governing permissions and limitations
+#  under the License.
+
+# SCDL parsing functions
+
+from util import *
+
+def mkcomponent(name, impl, svcs, refs):
+    return (name, impl, svcs, refs)
+
+def implementation(e):
+    if len(e) == 0 or match(car(e), "end", "component") == True:
+        return ""
+    if match(car(e), "start", "implementation.python") == False:
+        return implementation(cdr(e))
+    if "script" in att(car(e)):
+        s = att(car(e))["script"]
+        return s[0:len(s) - 3]
+    return None
+
+def binding(e):
+    if len(e) == 0 or match(car(e), "end", "reference") == True or match(car(e), "end", "service")
== True:
+        return ()
+    if match(car(e), "start", "binding.") == False:
+        return binding(cdr(e))
+    return tokens(att(car(e))["uri"])
+
+def references(e):
+    if len(e) == 0 or match(car(e), "end", "component") == True:
+        return ()
+    if match(car(e), "start", "reference") == False:
+        return references(cdr(e))
+    if "target" in att(car(e)):
+        return (att(car(e))["target"],) + references(cdr(e))
+    return cons(binding(e), references(cdr(e)))
+
+def services(e):
+    if len(e) == 0 or match(car(e), "end", "component") == True:
+        return ()
+    if match(car(e), "start", "service") == False:
+        return services(cdr(e))
+    return cons(binding(e), services(cdr(e)))
+
+def name(e):
+    return att(car(e))["name"]    
+
+def components(e):
+    if len(e) == 0:
+        return ()
+    if match(car(e), "start", "component") == False:
+        return components(cdr(e))
+    n = name(e)
+    return cons(mkcomponent(n, implementation(e), cons(("components", n), services(e)), references(e)),
components(cdr(e)))
+
+def nameToComponent(n, c):
+    if c == ():
+        return None
+    if car(car(c)) == n:
+        return car(c)
+    return nameToComponent(n, cdr(c))
+
+def matchingURI(u, s):
+    if s == ():
+        return None
+    if car(s) == u[0:len(car(s))]:
+        return car(s)
+    return matchingURI(u, cdr(s))
+
+def uriToComponent(u, c):
+    if c == ():
+        return (None, None)
+    m = matchingURI(u, caddr(car(c)))
+    if m != None:
+        return (m, car(c))
+    return uriToComponent(u, cdr(c))

Copied: tuscany/sca-cpp/trunk/modules/wsgi/server-test (from r917285, tuscany/sca-cpp/trunk/modules/Makefile.am)
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/modules/wsgi/server-test?p2=tuscany/sca-cpp/trunk/modules/wsgi/server-test&p1=tuscany/sca-cpp/trunk/modules/Makefile.am&r1=917285&r2=917286&rev=917286&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/modules/Makefile.am (original)
+++ tuscany/sca-cpp/trunk/modules/wsgi/server-test Sun Feb 28 20:01:44 2010
@@ -1,3 +1,5 @@
+#!/bin/sh
+
 #  Licensed to the Apache Software Foundation (ASF) under one
 #  or more contributor license agreements.  See the NOTICE file
 #  distributed with this work for additional information
@@ -15,8 +17,14 @@
 #  specific language governing permissions and limitations
 #  under the License.
 
-SUBDIRS = scheme atom json scdl http server python java
+# Setup
+./wsgi-start 8090
+sleep 2
 
-includedir = $(prefix)/include/modules
-nobase_include_HEADERS = */*.hpp
+# Test
+./client-test 2>/dev/null
+rc=$?
 
+# Cleanup
+./wsgi-stop 8090
+return $rc

Propchange: tuscany/sca-cpp/trunk/modules/wsgi/server-test
------------------------------------------------------------------------------
    svn:executable = *

Added: 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=917286&view=auto
==============================================================================
--- tuscany/sca-cpp/trunk/modules/wsgi/server-test.py (added)
+++ tuscany/sca-cpp/trunk/modules/wsgi/server-test.py Sun Feb 28 20:01:44 2010
@@ -0,0 +1,44 @@
+#  Licensed to the Apache Software Foundation (ASF) under one
+#  or more contributor license agreements.  See the NOTICE file
+#  distributed with this work for additional information
+#  regarding copyright ownership.  The ASF licenses this file
+#  to you under the Apache License, Version 2.0 (the
+#  "License"); you may not use this file except in compliance
+#  with the License.  You may obtain a copy of the License at
+#  
+#    http://www.apache.org/licenses/LICENSE-2.0
+#    
+#  Unless required by applicable law or agreed to in writing,
+#  software distributed under the License is distributed on an
+#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+#  KIND, either express or implied.  See the License for the
+#  specific language governing permissions and limitations
+#  under the License.
+
+# JSON-RPC test case
+
+def echo(x):
+    return x
+
+# ATOMPub test case
+
+def get(id):
+    if id == ("index.html",):
+        return ("text/plain", ("It works!",))
+    if id == ():
+        return ("Sample Feed", "123456789",
+            ("Item", "111", (("'javaClass", "services.Item"), ("'name", "Apple"), ("'currencyCode",
"USD"), ("'currencySymbol", "$"), ("'price", 2.99))),
+            ("Item", "222", (("'javaClass", "services.Item"), ("'name", "Orange"), ("'currencyCode",
"USD"), ("'currencySymbol", "$"), ("'price", 3.55))),
+            ("Item", "333", (("'javaClass", "services.Item"), ("name", "Pear"), ("'currencyCode",
"USD"), ("'currencySymbol", "$"), ("'price", 1.55))))
+        
+    entry = (("'javaClass", "services.Item"), ("'name", "Apple"), ("'currencyCode", "USD"),
("'currencySymbol", "$"), ("'price", 2.99))
+    return ("Item", id[0], entry)
+
+def post(collection, item):
+    return ("123456789",)
+
+def put(id, item):
+    return true
+
+def delete(id):
+    return true

Added: tuscany/sca-cpp/trunk/modules/wsgi/util.py
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/modules/wsgi/util.py?rev=917286&view=auto
==============================================================================
--- tuscany/sca-cpp/trunk/modules/wsgi/util.py (added)
+++ tuscany/sca-cpp/trunk/modules/wsgi/util.py Sun Feb 28 20:01:44 2010
@@ -0,0 +1,74 @@
+#  Licensed to the Apache Software Foundation (ASF) under one
+#  or more contributor license agreements.  See the NOTICE file
+#  distributed with this work for additional information
+#  regarding copyright ownership.  The ASF licenses this file
+#  to you under the Apache License, Version 2.0 (the
+#  "License"); you may not use this file except in compliance
+#  with the License.  You may obtain a copy of the License at
+#  
+#    http://www.apache.org/licenses/LICENSE-2.0
+#    
+#  Unless required by applicable law or agreed to in writing,
+#  software distributed under the License is distributed on an
+#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+#  KIND, either express or implied.  See the License for the
+#  specific language governing permissions and limitations
+#  under the License.
+
+# Simple utility functions
+
+from xml.etree.cElementTree import iterparse
+
+# Scheme-like lists
+def cons(a, b):
+    return (a,) + b
+
+def car(l):
+    return l[0]
+    
+def cdr(l):
+    return l[1:]
+
+def cadr(l):
+    return car(cdr(l))
+
+def cddr(l):
+    return cdr(cdr(l))
+
+def caddr(l):
+    return car(cddr(l))
+
+def nil(l):
+    return l == ()
+
+# Scheme-like associations
+def assoc(k, l):
+    if l == ():
+        return None
+    if k == car(car(l)):
+        return car(l)
+    return assoc(k, cdr(l))
+
+# Currying / partial function application
+def curry(f, *args):
+    return lambda *a: f(*(args + a))
+
+# Element tree utility functions
+def parse(file):
+    return map(lambda x: x, iterparse(file, events=("start", "end")))
+
+def evt(e):
+    return car(e)
+
+def elt(e):
+    return cadr(e)
+
+def att(e):
+    return elt(e).attrib
+
+def match(e, ev, tag):
+    return evt(e) == ev and elt(e).tag.find("}" + tag) != -1
+
+# Split a path
+def tokens(path):
+    return tuple(filter(lambda s: len(s) != 0, path.split("/")))

Added: tuscany/sca-cpp/trunk/modules/wsgi/wiring-test
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/modules/wsgi/wiring-test?rev=917286&view=auto
==============================================================================
--- tuscany/sca-cpp/trunk/modules/wsgi/wiring-test (added)
+++ tuscany/sca-cpp/trunk/modules/wsgi/wiring-test Sun Feb 28 20:01:44 2010
@@ -0,0 +1,69 @@
+#!/bin/sh
+
+#  Licensed to the Apache Software Foundation (ASF) under one
+#  or more contributor license agreements.  See the NOTICE file
+#  distributed with this work for additional information
+#  regarding copyright ownership.  The ASF licenses this file
+#  to you under the Apache License, Version 2.0 (the
+#  "License"); you may not use this file except in compliance
+#  with the License.  You may obtain a copy of the License at
+#  
+#    http://www.apache.org/licenses/LICENSE-2.0
+#    
+#  Unless required by applicable law or agreed to in writing,
+#  software distributed under the License is distributed on an
+#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+#  KIND, either express or implied.  See the License for the
+#  specific language governing permissions and limitations
+#  under the License.
+
+echo "Testing..."
+
+# Setup
+./wsgi-start 8090
+sleep 2
+
+# Test HTTP GET
+#curl http://localhost:8090/index.html 2>/dev/null >tmp/index.html
+#diff tmp/index.html ../server/htdocs/index.html
+#rc=$?
+rc="0"
+
+# Test ATOMPub
+if [ "$rc" = "0" ]; then
+    curl http://localhost:8090/client/ >tmp/feed.xml 2>/dev/null
+    diff tmp/feed.xml ../server/htdocs/feed.xml
+    rc=$?
+fi
+if [ "$rc" = "0" ]; then
+    curl http://localhost:8090/client/111 >tmp/entry.xml 2>/dev/null
+    diff tmp/entry.xml ../server/htdocs/entry.xml
+    rc=$?
+fi
+if [ "$rc" = "0" ]; then
+    curl http://localhost:8090/client/ -X POST -H "Content-type: application/atom+xml" --data
@../server/htdocs/entry.xml 2>/dev/null
+    rc=$?
+fi
+if [ "$rc" = "0" ]; then
+    curl http://localhost:8090/client/111 -X PUT -H "Content-type: application/atom+xml"
--data @../server/htdocs/entry.xml 2>/dev/null
+    rc=$?
+fi
+if [ "$rc" = "0" ]; then
+    curl http://localhost:8090/client/111 -X DELETE 2>/dev/null
+    rc=$?
+fi
+
+# Test JSON-RPC
+if [ "$rc" = "0" ]; then
+    curl http://localhost:8090/client/ -X POST -H "Content-type: application/json-rpc" --data
@../server/htdocs/json-request.txt >tmp/json-result.txt 2>/dev/null
+    diff tmp/json-result.txt ../server/htdocs/json-result.txt
+    rc=$?
+fi
+
+# Cleanup
+./wsgi-stop 8090
+sleep 2
+if [ "$rc" = "0" ]; then
+    echo "OK"
+fi
+return $rc

Propchange: tuscany/sca-cpp/trunk/modules/wsgi/wiring-test
------------------------------------------------------------------------------
    svn:executable = *

Copied: tuscany/sca-cpp/trunk/modules/wsgi/wsgi-start (from r917285, tuscany/sca-cpp/trunk/modules/Makefile.am)
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/modules/wsgi/wsgi-start?p2=tuscany/sca-cpp/trunk/modules/wsgi/wsgi-start&p1=tuscany/sca-cpp/trunk/modules/Makefile.am&r1=917285&r2=917286&rev=917286&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/modules/Makefile.am (original)
+++ tuscany/sca-cpp/trunk/modules/wsgi/wsgi-start Sun Feb 28 20:01:44 2010
@@ -1,3 +1,5 @@
+#!/bin/sh
+
 #  Licensed to the Apache Software Foundation (ASF) under one
 #  or more contributor license agreements.  See the NOTICE file
 #  distributed with this work for additional information
@@ -15,8 +17,10 @@
 #  specific language governing permissions and limitations
 #  under the License.
 
-SUBDIRS = scheme atom json scdl http server python java
+# Start WSGI server
+here=`readlink -f $0`; here=`dirname $here`
+port=$1
 
-includedir = $(prefix)/include/modules
-nobase_include_HEADERS = */*.hpp
+python_prefix=`cat $here/../python/python.prefix`
+$python_prefix/bin/python composite.py $port &
 

Propchange: tuscany/sca-cpp/trunk/modules/wsgi/wsgi-start
------------------------------------------------------------------------------
    svn:executable = *

Copied: tuscany/sca-cpp/trunk/modules/wsgi/wsgi-stop (from r917285, tuscany/sca-cpp/trunk/modules/Makefile.am)
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/modules/wsgi/wsgi-stop?p2=tuscany/sca-cpp/trunk/modules/wsgi/wsgi-stop&p1=tuscany/sca-cpp/trunk/modules/Makefile.am&r1=917285&r2=917286&rev=917286&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/modules/Makefile.am (original)
+++ tuscany/sca-cpp/trunk/modules/wsgi/wsgi-stop Sun Feb 28 20:01:44 2010
@@ -1,3 +1,5 @@
+#!/bin/sh
+
 #  Licensed to the Apache Software Foundation (ASF) under one
 #  or more contributor license agreements.  See the NOTICE file
 #  distributed with this work for additional information
@@ -15,8 +17,11 @@
 #  specific language governing permissions and limitations
 #  under the License.
 
-SUBDIRS = scheme atom json scdl http server python java
+# Stop WSGI server
+here=`readlink -f $0`; here=`dirname $here`
+port=$1
 
-includedir = $(prefix)/include/modules
-nobase_include_HEADERS = */*.hpp
+python_prefix=`cat $here/../python/python.prefix`
+py="$python_prefix/bin/python composite.py $port"
 
+kill `ps -f | grep -v grep | grep "${py}" | awk '{ print $2 }'`

Propchange: tuscany/sca-cpp/trunk/modules/wsgi/wsgi-stop
------------------------------------------------------------------------------
    svn:executable = *



Mime
View raw message