summaryrefslogtreecommitdiffstats
path: root/sca-cpp/trunk/modules/python
diff options
context:
space:
mode:
authorjsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68>2010-01-17 09:02:29 +0000
committerjsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68>2010-01-17 09:02:29 +0000
commitb00fe2747627bc95ac8d1d548e0621930a1775a2 (patch)
tree64561e332127d72763850196be5f0538cac9b8bb /sca-cpp/trunk/modules/python
parent9cb610814d58da1ba2617f78e36e9635f2e7d508 (diff)
Cleaned up test composite files. Adjusted C++ implementation elements to match the spec. Minor refactoring/terminology cleanup in HTTPD modules, renamed readImplementation to evalImplementation and evalImplementation to applyImplementation.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@900071 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-cpp/trunk/modules/python')
-rw-r--r--sca-cpp/trunk/modules/python/domain-test.composite4
-rw-r--r--sca-cpp/trunk/modules/python/mod-python.cpp11
-rw-r--r--sca-cpp/trunk/modules/python/mod-python.hpp30
-rw-r--r--sca-cpp/trunk/modules/python/tuscany-sca-1.1-implementation-python.xsd2
4 files changed, 25 insertions, 22 deletions
diff --git a/sca-cpp/trunk/modules/python/domain-test.composite b/sca-cpp/trunk/modules/python/domain-test.composite
index 7318f96520..a0e92dfb0c 100644
--- a/sca-cpp/trunk/modules/python/domain-test.composite
+++ b/sca-cpp/trunk/modules/python/domain-test.composite
@@ -23,14 +23,14 @@
name="domain-test">
<component name="python-test">
- <t:implementation.python uri="server-test.py"/>
+ <t:implementation.python script="server-test.py"/>
<service name="test">
<t:binding.http uri="python"/>
</service>
</component>
<component name="client-test">
- <t:implementation.python uri="client-test.py"/>
+ <t:implementation.python script="client-test.py"/>
<service name="client">
<t:binding.http uri="client"/>
</service>
diff --git a/sca-cpp/trunk/modules/python/mod-python.cpp b/sca-cpp/trunk/modules/python/mod-python.cpp
index 1352c50c11..1c35467b4b 100644
--- a/sca-cpp/trunk/modules/python/mod-python.cpp
+++ b/sca-cpp/trunk/modules/python/mod-python.cpp
@@ -37,14 +37,15 @@ namespace server {
namespace modeval {
/**
- * Return a configured component implementation.
- * For now only Scheme and C++ implementations are supported.
+ * Evaluate a Python component implementation and convert it to an applicable
+ * lambda function.
*/
-const failable<lambda<value(const list<value>&)> > readImplementation(const string& itype, const string& path, const list<value>& px) {
+const failable<lambda<value(const list<value>&)> > evalImplementation(const string& path, const value& impl, const list<value>& px) {
+ const string itype(elementName(impl));
if (contains(itype, ".python"))
- return modpython::readImplementation(path, px);
+ return modpython::evalImplementation(path, impl, px);
if (contains(itype, ".cpp"))
- return modcpp::readImplementation(path, px);
+ return modcpp::evalImplementation(path, impl, px);
return mkfailure<lambda<value(const list<value>&)> >(string("Unsupported implementation type: ") + itype);
}
diff --git a/sca-cpp/trunk/modules/python/mod-python.hpp b/sca-cpp/trunk/modules/python/mod-python.hpp
index a56232d641..e67b9a4a93 100644
--- a/sca-cpp/trunk/modules/python/mod-python.hpp
+++ b/sca-cpp/trunk/modules/python/mod-python.hpp
@@ -23,7 +23,7 @@
#define tuscany_modpython_hpp
/**
- * Evaluation functions used by mod-eval to evaluate implementation.python
+ * Evaluation functions used by mod-eval to evaluate Python
* component implementations.
*/
@@ -41,18 +41,18 @@ namespace server {
namespace modpython {
/**
- * Evaluate a script component implementation function.
+ * Apply a Python component implementation function.
*/
-struct evalImplementation {
+struct applyImplementation {
PyObject* impl;
const list<value> px;
- evalImplementation(PyObject* impl, const list<value>& px) : impl(impl), px(px) {
+ applyImplementation(PyObject* impl, const list<value>& px) : impl(impl), px(px) {
}
const value operator()(const list<value>& params) const {
const value expr = append<value>(params, px);
- debug(expr, "modeval::python::evalImplementation::input");
+ debug(expr, "modeval::python::applyImplementation::input");
const failable<value> val = python::evalScript(expr, impl);
- debug(val, "modeval::python::evalImplementation::result");
+ debug(val, "modeval::python::applyImplementation::result");
if (!hasContent(val))
return mklist<value>(value(), reason(val));
return mklist<value>(content(val));
@@ -60,16 +60,18 @@ struct evalImplementation {
};
/**
- * Read a script component implementation.
+ * Evaluate a Python component implementation and convert it to an applicable
+ * lambda function.
*/
-const failable<lambda<value(const list<value>&)> > readImplementation(const string& path, const list<value>& px) {
- ifstream is(path);
+const failable<lambda<value(const list<value>&)> > evalImplementation(const string& path, const value& impl, const list<value>& px) {
+ const string fpath(path + attributeValue("script", impl));
+ ifstream is(fpath);
if (fail(is))
- return mkfailure<lambda<value(const list<value>&)> >(string("Could not read implementation: ") + path);
- const failable<PyObject*> impl = python::readScript(path, is);
- if (!hasContent(impl))
- return mkfailure<lambda<value(const list<value>&)> >(reason(impl));
- return lambda<value(const list<value>&)>(evalImplementation(content(impl), px));
+ return mkfailure<lambda<value(const list<value>&)> >(string("Could not read implementation: ") + fpath);
+ const failable<PyObject*> script = python::readScript(fpath, is);
+ if (!hasContent(script))
+ return mkfailure<lambda<value(const list<value>&)> >(reason(script));
+ return lambda<value(const list<value>&)>(applyImplementation(content(script), px));
}
}
diff --git a/sca-cpp/trunk/modules/python/tuscany-sca-1.1-implementation-python.xsd b/sca-cpp/trunk/modules/python/tuscany-sca-1.1-implementation-python.xsd
index 95ffc4f743..24d5e224bc 100644
--- a/sca-cpp/trunk/modules/python/tuscany-sca-1.1-implementation-python.xsd
+++ b/sca-cpp/trunk/modules/python/tuscany-sca-1.1-implementation-python.xsd
@@ -34,7 +34,7 @@
<any namespace="##targetNamespace" processContents="lax"
minOccurs="0" maxOccurs="unbounded"/>
</sequence>
- <attribute name="location" type="anyURI" use="required"/>
+ <attribute name="script" type="anyURI" use="required"/>
<anyAttribute namespace="##any" processContents="lax"/>
</extension>
</complexContent>