Author: ajborley
Date: Wed Jan  3 11:47:23 2007
New Revision: 492270

URL: http://svn.apache.org/viewvc?view=rev&rev=492270
Log:
Added initial support for named parameters (aka keyword arguments) to Python & 
REST references

Modified:
    incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/core/Operation.cpp
    incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/core/Operation.h
    
incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/ReferenceBinding.cpp
    
incubator/tuscany/cpp/sca/runtime/extensions/python/src/tuscany/sca/python/PythonServiceWrapper.cpp
    
incubator/tuscany/cpp/sca/runtime/extensions/python/src/tuscany/sca/python/sca_module.cpp
    
incubator/tuscany/cpp/sca/runtime/extensions/python/src/tuscany/sca/python/sca_proxy.py
    
incubator/tuscany/cpp/sca/runtime/extensions/rest/reference/curl/src/tuscany/sca/rest/RESTServiceWrapper.cpp

Modified: 
incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/core/Operation.cpp
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/core/Operation.cpp?view=diff&rev=492270&r1=492269&r2=492270
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/core/Operation.cpp 
(original)
+++ incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/core/Operation.cpp 
Wed Jan  3 11:47:23 2007
@@ -145,9 +145,25 @@
             return 0;
         }
 
-        // ==============================================
-        // getParameter: return of parameter
-        // ==============================================
+        // ==================================================
+        // getParameter: return parameter value based on name
+        // ==================================================
+        void* Operation::getParameterValue(const string& name) const
+        {
+            logentry();
+            try
+            {
+                return getParameter(name).getValue();
+            }
+            catch(ServiceInvocationException)
+            {}
+
+            return 0;
+        }
+
+        // ======================================================
+        // getParameter: return parameter based on index position
+        // ======================================================
         const Operation::Parameter& Operation::getParameter(unsigned int pos) 
const
         {
             logentry();
@@ -159,10 +175,27 @@
             throwException(ServiceInvocationException, "Index out of range");
         }
 
+        // ===============================================
+        // getParameter: return of parameter based on name
+        // ===============================================
+        const Operation::Parameter& Operation::getParameter(const string& 
name) const
+        {
+            logentry();
+            for(unsigned int pos=0; pos < parameters.size(); pos++)
+            {
+                if(parameters[pos].getName() == name)
+                {
+                    return parameters[pos];
+                }
+            }
+            
+            throwException(ServiceInvocationException, "Parameter name not 
found");
+        }
 
-        // ==============================================
-        // getParameterType: return type of parameter
-        // ==============================================
+
+        // ============================================================
+        // getParameterType: return type of parameter based on position
+        // ============================================================
         Operation::ParameterType Operation::getParameterType(unsigned int pos) 
const
         {
             logentry();
@@ -174,6 +207,38 @@
             return VOID_TYPE;
         }
 
+        // ========================================================
+        // getParameterType: return type of parameter based on name
+        // ========================================================
+        Operation::ParameterType Operation::getParameterType(const string& 
name) const
+        {
+            logentry();
+            try
+            {
+                return getParameter(name).getType();
+            }
+            catch(ServiceInvocationException)
+            {}
+
+            return VOID_TYPE;
+        }
+
+        const string emptyString = string();
+
+        // ==============================================
+        // getParameterName: return name of parameter
+        // ==============================================
+        const string& Operation::getParameterName(unsigned int pos) const
+        {
+            logentry();
+            if (pos < parameters.size())
+            {
+                return parameters[pos].getName();
+            }
+            
+            return emptyString;
+        }
+
         // ===========================================
         // addParameter: set parameter at position pos
         // ===========================================
@@ -284,8 +349,118 @@
             parameters.insert(parameters.end(), Parameter((void*)new 
DataObjectPtr(*parm), DATAOBJECT));
         }
 
-        Operation::Parameter::Parameter(void* val, Operation::ParameterType 
typ)
-            : value(val), type(typ)
+        // =======================================================
+        // addParameter: set parameter at position pos with a name
+        // =======================================================
+        void Operation::addParameter(const string& name, const void *parm)
+        {
+            logentry();
+            loginfo("Adding operation parameter, name: %s, type: void, value: 
%p", name.c_str(), parm);
+            parameters.insert(parameters.end(), Parameter((void*)parm, 
VOID_TYPE, (string&) name));
+         }
+
+        void Operation::addParameter(const string& name, const bool *parm)
+        {
+            logentry();
+            loginfo("Adding operation parameter, name: %s, type: bool, value: 
%d", name.c_str(), (int)*parm);
+            parameters.insert(parameters.end(), Parameter((void*)parm, BOOL, 
(string&) name));
+        }
+
+        void Operation::addParameter(const string& name, const short *parm)
+        {
+            logentry();
+            loginfo("Adding operation parameter, name: %s, type: short, value: 
%hd", name.c_str(), (short)*parm);
+            parameters.insert(parameters.end(), Parameter((void*)parm, SHORT, 
(string&) name));
+        }
+
+        void Operation::addParameter(const string& name, const int *parm)
+        {
+            logentry();
+            loginfo("Adding operation parameter, name: %s, type: int, value: 
%d", name.c_str(), (int)*parm);
+            parameters.insert(parameters.end(), Parameter((void*)parm, INT, 
(string&) name));
+        }
+
+        void Operation::addParameter(const string& name, const long *parm)
+        {
+            logentry();
+            loginfo("Adding operation parameter, name: %s, type: long, value: 
%ld", name.c_str(), (long)*parm);
+            parameters.insert(parameters.end(), Parameter((void*)parm, LONG, 
(string&) name));
+        }
+
+        void Operation::addParameter(const string& name, const unsigned short 
*parm)
+        {
+            logentry();
+            loginfo("Adding operation parameter, name: %s, type: unsigned 
short, value: %hu", (unsigned short)*parm);
+            parameters.insert(parameters.end(), Parameter((void*)parm, USHORT, 
(string&) name));
+        }
+
+        void Operation::addParameter(const string& name, const unsigned int 
*parm)
+        {
+            logentry();
+            loginfo("Adding operation parameter, name: %s, type: unsigned int, 
value: %u", name.c_str(), (unsigned int)*parm);
+            parameters.insert(parameters.end(), Parameter((void*)parm, UINT, 
(string&) name));
+        }
+
+        void Operation::addParameter(const string& name, const unsigned long 
*parm)
+        {
+            logentry();
+            loginfo("Adding operation parameter, name: %s, type: unsigned 
long, value: %lu", name.c_str(), (unsigned long)*parm);
+            parameters.insert(parameters.end(), Parameter((void*)parm, ULONG, 
(string&) name));
+        }
+
+       void Operation::addParameter(const string& name, const float *parm)
+        {
+            logentry();
+            loginfo("Adding operation parameter, name: %s, type: float, value: 
%f", name.c_str(), (float)*parm);
+            parameters.insert(parameters.end(), Parameter((void*)parm, FLOAT, 
(string&) name));
+        }
+
+       void Operation::addParameter(const string& name, const double *parm)
+        {
+            logentry();
+            loginfo("Adding operation parameter, name: %s, type: double, 
value: %lf", name.c_str(), (double)*parm);
+            parameters.insert(parameters.end(), Parameter((void*)parm, DOUBLE, 
(string&) name));
+        }
+
+       void Operation::addParameter(const string& name, const long double 
*parm)
+        {
+            logentry();
+            loginfo("Adding operation parameter, name: %s, type: long double, 
value: %Lf", name.c_str(), (long double)*parm);
+            parameters.insert(parameters.end(), Parameter((void*)parm, 
LONGDOUBLE, (string&) name));
+        }
+
+        void Operation::addParameter(const string& name, const char* *parm)
+        {
+            logentry();
+            loginfo("Adding operation parameter, name: %s, type: char*, value: 
%s", name.c_str(), (const char*)*parm);
+            parameters.insert(parameters.end(), Parameter((void*)parm, CHARS, 
(string&) name));
+        }
+
+        void Operation::addParameter(const string& name, const char *parm)
+        {
+            logentry();
+            loginfo("Adding operation parameter, name: %s, type: char, value: 
%d", name.c_str(), (int)*parm);
+            parameters.insert(parameters.end(), Parameter((void*)parm, CHAR, 
(string&) name));
+        }
+
+        void Operation::addParameter(const string& name, const string *parm)
+        {
+            logentry();
+            loginfo("Adding operation parameter, name: %s, type: string, 
value: %s", (const char*)(*parm).c_str());
+            parameters.insert(parameters.end(), Parameter((void*)parm, STRING, 
(string&) name));
+        }
+
+        void Operation::addParameter(const string& name, const DataObjectPtr 
*parm)
+        {
+            logentry();
+            ostringstream os;
+            os << *parm;
+            loginfo("Adding operation parameter, name: %s, type: DataObject, 
value: %s", name.c_str(), os.str().c_str());
+            parameters.insert(parameters.end(), Parameter((void*)new 
DataObjectPtr(*parm), DATAOBJECT, (string&) name));
+        }
+
+        Operation::Parameter::Parameter(void* val, Operation::ParameterType 
typ, string& nam)
+            : value(val), type(typ), name(nam)
         {
         }
 

Modified: 
incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/core/Operation.h
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/core/Operation.h?view=diff&rev=492270&r1=492269&r2=492270
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/core/Operation.h 
(original)
+++ incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/core/Operation.h Wed 
Jan  3 11:47:23 2007
@@ -95,11 +95,14 @@
             class Parameter
             {
                 public:
-                    SCA_API Parameter(void* value = NULL, ParameterType type = 
VOID_TYPE);
+                    SCA_API Parameter(void* value = NULL, ParameterType type = 
VOID_TYPE, std::string& name = std::string(""));
                     SCA_API void* getValue() const {return value;}
                     SCA_API ParameterType getType() const {return type;}
+                    SCA_API const std::string& getName() const {return name;}
+                    SCA_API bool hasName() const {return (name.length() > 0);}
 
                 private:
+                    std::string name;
                     void* value;
                     ParameterType type;
             };
@@ -126,7 +129,6 @@
 
             /**
              * Set a parameter on the operation.
-             * @param pos The position of the parameter in the parameter list.
              * @param parm Pointer to the parameter to be passed.
              */
             SCA_API void addParameter(const void *parm);
@@ -144,6 +146,27 @@
             SCA_API void addParameter(const char* *parm);
             SCA_API void addParameter(const std::string *parm);
             SCA_API void addParameter(const commonj::sdo::DataObjectPtr *parm);
+
+            /**
+             * Set a parameter on the operation.
+             * @param name The name of the parameter in the parameter list.
+             * @param parm Pointer to the parameter to be passed.
+             */
+            SCA_API void addParameter(const std::string& name, const void 
*parm);
+            SCA_API void addParameter(const std::string& name, const bool 
*parm);
+            SCA_API void addParameter(const std::string& name, const short 
*parm);
+            SCA_API void addParameter(const std::string& name, const int 
*parm);
+            SCA_API void addParameter(const std::string& name, const long 
*parm);
+            SCA_API void addParameter(const std::string& name, const unsigned 
short *parm);
+            SCA_API void addParameter(const std::string& name, const unsigned 
int *parm);
+            SCA_API void addParameter(const std::string& name, const unsigned 
long *parm);
+            SCA_API void addParameter(const std::string& name, const float 
*parm);
+            SCA_API void addParameter(const std::string& name, const double 
*parm);
+            SCA_API void addParameter(const std::string& name, const long 
double *parm);
+            SCA_API void addParameter(const std::string& name, const char 
*parm);
+            SCA_API void addParameter(const std::string& name, const char* 
*parm);
+            SCA_API void addParameter(const std::string& name, const 
std::string *parm);
+            SCA_API void addParameter(const std::string& name, const 
commonj::sdo::DataObjectPtr *parm);
             
             SCA_API unsigned int getNParms() const {return parameters.size();}
 
@@ -156,20 +179,49 @@
             SCA_API const Parameter& getParameter(unsigned int pos) const;
 
             /**
+             * Get a parameter from the operation.
+             * @param name The name of the parameter in the parameter list.
+             * @return Pointer to the paramter with the given name. Should be
+             * cast to the appropriate type.
+             */
+            SCA_API const Parameter& getParameter(const std::string& name) 
const;
+
+            /**
              * Get a parameter type from the operation.
              * @param pos The position of the parameter in the parameter list.
-             * @return Pointer to the paramter at the given postion. Should be
-             * cast to the appropriate type.
+             * @return Type of the parameter at the given position.
              */
             SCA_API ParameterType getParameterType(unsigned int pos) const;
 
             /**
-             * Get a parameter from the operation.
+             * Get a parameter type from the operation.
+             * @param name The name of the parameter in the parameter list.
+             * @return Type of the parameter with the given name.
+             */
+            SCA_API ParameterType getParameterType(const std::string& name) 
const;
+
+            /**
+             * Get a parameter name from the operation.
              * @param pos The position of the parameter in the parameter list.
-             * @return Pointer to the paramter at the given postion. Should be
+             * @return Name of the parameter at the given position.
+             */
+            SCA_API const std::string& getParameterName(unsigned int pos) 
const;
+
+            /**
+             * Get the parameter value from the operation.
+             * @param pos The position of the parameter in the parameter list.
+             * @return Pointer to the value of the parameter at the given 
postion. Should be
              * cast to the appropriate type.
              */
             SCA_API void* getParameterValue(unsigned int pos) const;
+
+            /**
+             * Get the parameter value from the operation.
+             * @param name The name of the parameter in the parameter list.
+             * @return Pointer to the value of the parameter with the given 
name. Should be
+             * cast to the appropriate type.
+             */
+            SCA_API void* getParameterValue(const std::string& name) const;
 
             SCA_API ParameterType getReturnType() const {return 
returnValue.getType();}
             SCA_API void* getReturnValue() const {return 
returnValue.getValue();}

Modified: 
incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/ReferenceBinding.cpp
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/ReferenceBinding.cpp?view=diff&rev=492270&r1=492269&r2=492270
==============================================================================
--- 
incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/ReferenceBinding.cpp
 (original)
+++ 
incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/ReferenceBinding.cpp
 Wed Jan  3 11:47:23 2007
@@ -52,6 +52,8 @@
 
             void ReferenceBinding::configure(const string& uri)
             {
+                logentry();
+
                 // Find the target service
                 Component* component = reference->getComponent();
                 Composite* composite = component->getComposite();

Modified: 
incubator/tuscany/cpp/sca/runtime/extensions/python/src/tuscany/sca/python/PythonServiceWrapper.cpp
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/extensions/python/src/tuscany/sca/python/PythonServiceWrapper.cpp?view=diff&rev=492270&r1=492269&r2=492270
==============================================================================
--- 
incubator/tuscany/cpp/sca/runtime/extensions/python/src/tuscany/sca/python/PythonServiceWrapper.cpp
 (original)
+++ 
incubator/tuscany/cpp/sca/runtime/extensions/python/src/tuscany/sca/python/PythonServiceWrapper.cpp
 Wed Jan  3 11:47:23 2007
@@ -288,6 +288,7 @@
                     if (pFunc && PyCallable_Check(pFunc)) 
                     {
                         PyObject* pArgs = PyTuple_New(operation.getNParms());
+                        PyObject* pKeywordsDict = PyDict_New();
                         PyObject* pValue = NULL;
 
                         // Load up the xml.etree.ElementTree module for 
dealing with SDO params and return values
@@ -407,13 +408,27 @@
                                 throwException(ServiceDataException, 
msg.c_str());
                                 
                             }
-                            //printPyObject("Param value", pValue);
+                            //printPyObject("Param value", pValue);            
                                            
 
-                            /* pValue reference stolen here: */
-                            PyTuple_SetItem(pArgs, i, pValue);
+                            // If we have a param name, put it in the keyword 
args
+                            if(parm.hasName())
+                            {
+                                PyDict_SetItemString(pKeywordsDict, 
parm.getName().c_str(), pValue);
+                                Py_DECREF(pValue);
+                            }
+                            else
+                            {   
+                                /* pValue reference stolen here: */
+                                PyTuple_SetItem(pArgs, i, pValue);
+                            }
                         }
 
-                        pValue = PyObject_CallObject(pFunc, pArgs);
+                        // Resize the args to the correct length
+                        _PyTuple_Resize(&pArgs, operation.getNParms() - 
PyDict_Size(pKeywordsDict));
+
+                        loginfo("Calling python func with %d args and %d 
keyword args", PyTuple_Size(pArgs), PyDict_Size(pKeywordsDict));
+
+                        pValue = PyObject_Call(pFunc, pArgs, pKeywordsDict);
                         //printPyObject("Return value", pValue);
 
                         Py_DECREF(pArgs);
@@ -871,7 +886,7 @@
                 DataObjectPtr properties = component->getProperties();
                 PropertyList pl = properties->getInstanceProperties();
 
-                for (int i = 0; i < pl.size(); i++)
+                for (unsigned int i = 0; i < pl.size(); i++)
                 {
                     if (properties->isSet(pl[i]))
                     {

Modified: 
incubator/tuscany/cpp/sca/runtime/extensions/python/src/tuscany/sca/python/sca_module.cpp
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/extensions/python/src/tuscany/sca/python/sca_module.cpp?view=diff&rev=492270&r1=492269&r2=492270
==============================================================================
--- 
incubator/tuscany/cpp/sca/runtime/extensions/python/src/tuscany/sca/python/sca_module.cpp
 (original)
+++ 
incubator/tuscany/cpp/sca/runtime/extensions/python/src/tuscany/sca/python/sca_module.cpp
 Wed Jan  3 11:47:23 2007
@@ -58,8 +58,9 @@
 */
 static void printPyObject(char* prefix, char* name, PyObject* pObj)
 {
-    PyObject* pObjRepr = PyObject_Repr(pObj);    
-    loginfo("%s printPyObject %s: %s", prefix, name, 
PyString_AsString(pObjRepr));
+    PyObject* pObjRepr = PyObject_Repr(pObj);   
+    PyTypeObject* type = pObj->ob_type;
+    loginfo("%s printPyObject (%s) %s = %s", prefix, type->tp_name, name, 
PyString_AsString(pObjRepr));
     Py_XDECREF(pObjRepr);
 
     if(pObj != NULL)
@@ -216,7 +217,7 @@
 
     if(operationName.size() > 0)
     {
-        loginfo("Operation: %s", operationName.c_str());
+        loginfo("sca_invoke Operation name: %s", operationName.c_str());
     }
     else
     {
@@ -235,46 +236,67 @@
 
     // Parameters are the fourth argument
     PyObject* paramTuple = PyTuple_GetItem(args, 3);
+    unsigned int numberOfArgs = (unsigned int) PyTuple_Size(paramTuple);
+    loginfo("sca_invoke %d arg parameters supplied", numberOfArgs);
+    
+    // Keyword parameters (AKA named arguments) are the fifth argument
+    PyObject* keywordParamDict = PyTuple_GetItem(args, 4);
+    loginfo("sca_invoke %d keyword parameters supplied", 
PyDict_Size(keywordParamDict));
+    
+    PyObject* paramKeys = PyDict_Keys(keywordParamDict);   
 
-    // Go through the supplied parameters
-    for(int i=0; i < PyTuple_Size(paramTuple); i++)
+    // Go through all the supplied parameters (args and keyword args)
+    for(unsigned int i=0; i < (numberOfArgs + PyList_Size(paramKeys)); i++)
     {
-        PyObject* param = PyTuple_GetItem(paramTuple, i);
+        string* paramName;
+        PyObject* param;
+
+        if(i < PyTuple_Size(paramTuple))
+        {
+            param = PyTuple_GetItem(paramTuple, i);
+            paramName = new string();
+        }
+        else
+        {
+            PyObject* key = PyList_GetItem(paramKeys, i-numberOfArgs);
+            param = PyDict_GetItem(keywordParamDict, key);
+            paramName = new string(PyString_AsString(key));
+        }
 
         if(PyInt_Check(param))
         {
-            loginfo("Int param %d: %d", i, PyInt_AsLong(param));
+            loginfo("Int param %d %s: %d", i, (*paramName).c_str(), 
PyInt_AsLong(param));
             long* intData = new long;
             *intData = PyInt_AsLong(param);
-            operation.addParameter(intData);
+            operation.addParameter(*paramName, intData);
         }
         else if(PyBool_Check(param))
         {
-            loginfo("Bool param %d: %d", i, (param == Py_True));
+            loginfo("Bool param %d %s: %d", i, (*paramName).c_str(), (param == 
Py_True));
             bool* boolData = new bool;
             *boolData = (param == Py_True);
-            operation.addParameter(boolData);
+            operation.addParameter(*paramName, boolData);
         }
         else if(PyLong_Check(param))
         {
-            loginfo("Long param %d: %l", i, PyLong_AsLong(param));
+            loginfo("Long param %d %s: %l", i, (*paramName).c_str(), 
PyLong_AsLong(param));
             long* longData = new long;
             *longData = PyLong_AsLong(param);
-            operation.addParameter(longData);
+            operation.addParameter(*paramName, longData);
         }
         else if(PyFloat_Check(param))
         {
-            loginfo("Float param %d: %f", i, PyFloat_AsDouble(param));
+            loginfo("Float param %d %s: %f", i, (*paramName).c_str(), 
PyFloat_AsDouble(param));
             double* doubleData = new double;
             *doubleData = PyFloat_AsDouble(param);
-            operation.addParameter(doubleData);
+            operation.addParameter(*paramName, doubleData);
         }
         else if(PyString_Check(param))
         {
-            loginfo("String param %d: %s", i, PyString_AsString(param));
+            loginfo("String param %d %s: %s", i, (*paramName).c_str(), 
PyString_AsString(param));
             const char** stringData = new const char*; 
             *stringData = PyString_AsString(param);
-            operation.addParameter(stringData);
+            operation.addParameter(*paramName, stringData);
         }
         else
         {
@@ -290,7 +312,8 @@
                 PyObject* elementTreeToStringFunc = 
PyObject_GetAttrString(elementTreeModule, "tostring");
                 PyObject* pElemString = 
PyObject_CallFunction(elementTreeToStringFunc, "O", param);
                 char* data = PyString_AsString(pElemString);
-                
+                loginfo("SDO param %d %s: %s", i, (*paramName).c_str(), data);
+
                 Py_DECREF(elementTreeToStringFunc);
                 Py_DECREF(pElemString);
 
@@ -311,7 +334,7 @@
                 }
                 if (*dataObjectData != NULL)
                 {
-                    operation.addParameter(dataObjectData);
+                    operation.addParameter(*paramName, dataObjectData);
                 }
                 else
                 {
@@ -475,8 +498,8 @@
 }
 static PyMethodDef ModuleMethods[] = 
 {
-    {"locateservice", sca_locateservice, METH_VARARGS, "Locates an SCA service 
& returns an sca_proxy_class instance"},
-    {"invoke", sca_invoke, METH_VARARGS, "Invoke an operation on an SCA 
service or reference"},
+    {"locateservice", (PyCFunction) sca_locateservice, METH_VARARGS, "Locates 
an SCA service & returns an sca_proxy_class instance"},
+    {"invoke", (PyCFunction) sca_invoke, METH_VARARGS, "Invoke an operation on 
an SCA service or reference"},
     {NULL, NULL, 0, NULL}        /* Sentinel */
 };
 

Modified: 
incubator/tuscany/cpp/sca/runtime/extensions/python/src/tuscany/sca/python/sca_proxy.py
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/extensions/python/src/tuscany/sca/python/sca_proxy.py?view=diff&rev=492270&r1=492269&r2=492270
==============================================================================
--- 
incubator/tuscany/cpp/sca/runtime/extensions/python/src/tuscany/sca/python/sca_proxy.py
 (original)
+++ 
incubator/tuscany/cpp/sca/runtime/extensions/python/src/tuscany/sca/python/sca_proxy.py
 Wed Jan  3 11:47:23 2007
@@ -40,8 +40,9 @@
 
     def invoke(self, operationName):
         
-        def invokeFunction(*args,**kwargs):
-            return sca.invoke(self.sca_proxy_name, 
self.sca_proxy_is_reference, operationName, args)
+        def invokeFunction(*args, **kwargs):
+            # Pass the args and keywords in to the invoke method as arguments
+            return sca.invoke(self.sca_proxy_name, 
self.sca_proxy_is_reference, operationName, args, kwargs)
 
         return invokeFunction
 

Modified: 
incubator/tuscany/cpp/sca/runtime/extensions/rest/reference/curl/src/tuscany/sca/rest/RESTServiceWrapper.cpp
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/extensions/rest/reference/curl/src/tuscany/sca/rest/RESTServiceWrapper.cpp?view=diff&rev=492270&r1=492269&r2=492270
==============================================================================
--- 
incubator/tuscany/cpp/sca/runtime/extensions/rest/reference/curl/src/tuscany/sca/rest/RESTServiceWrapper.cpp
 (original)
+++ 
incubator/tuscany/cpp/sca/runtime/extensions/rest/reference/curl/src/tuscany/sca/rest/RESTServiceWrapper.cpp
 Wed Jan  3 11:47:23 2007
@@ -269,10 +269,20 @@
                             // If the URI ends with a "?" then we use the query
                             // form param=value&
                             os << uri;
-                            for (int i = firstParm; i < operation.getNParms(); 
i++)
+                            for (unsigned int i = firstParm; i < 
operation.getNParms(); i++)
                             {
-                                os << "param" << (i + 1) << "=";
-                                writeParameter(xmlHelper, os, 
operation.getParameter(i));
+                                Operation::Parameter param = 
operation.getParameter(i);
+
+                                if(param.hasName())
+                                {
+                                    os << param.getName() << "=";
+                                }
+                                else
+                                {
+                                    // No name - use "param1", etc
+                                    os << "param" << (i + 1) << "=";
+                                }
+                                writeParameter(xmlHelper, os, param);
                                 if (i < operation.getNParms()-1)
                                     os << "&";
                             }
@@ -282,14 +292,15 @@
                             // Add the parameters in the form
                             // value1 / value2 / value3 
                             os << uri;
-                            for (int i = firstParm; i < operation.getNParms(); 
i++)
+                            for (unsigned int i = firstParm; i < 
operation.getNParms(); i++)
                             {
                                 os << "/";
                                 writeParameter(xmlHelper, os, 
operation.getParameter(i));
                             }
                         }
     
-                        string url = os.str();                                 
       
+                        string url = os.str(); 
+                        //loginfo("RESTServiceWrapper: HTTP GET %s", 
url.c_str());
                         curl_easy_setopt(curl_handle, CURLOPT_URL, 
url.c_str());
      
                         // Send all data to this function
@@ -468,10 +479,19 @@
                             // If the URI ends with a "?" then we use the query
                             // form param=value&
                             os << uri;
-                            for (int i = firstParm; i < 
operation.getNParms()-1; i++)
+                            for (unsigned int i = firstParm; i < 
operation.getNParms()-1; i++)
                             {
-                                os << "param" << (i + 1) << "=";
-                                writeParameter(xmlHelper, os, 
operation.getParameter(i));
+                                Operation::Parameter param = 
operation.getParameter(i);
+                                if(param.hasName())
+                                {
+                                    os << param.getName() << "=";
+                                }
+                                else
+                                {
+                                    // No name - use "param1", etc
+                                    os << "param" << (i + 1) << "=";
+                                }
+                                writeParameter(xmlHelper, os, param);
                                 if (i < operation.getNParms()-1)
                                     os << "&";
                             }
@@ -481,7 +501,7 @@
                             // Add the parameters in the form
                             // value1 / value2 / value3 
                             os << uri;
-                            for (int i = firstParm; i < 
operation.getNParms()-1; i++)
+                            for (unsigned int i = firstParm; i < 
operation.getNParms()-1; i++)
                             {
                                 os << "/";
                                 writeParameter(xmlHelper, os, 
operation.getParameter(i));
@@ -593,10 +613,20 @@
                             // If the URI ends with a "?" then we use the query
                             // form param=value&
                             os << uri;
-                            for (int i = firstParm; i < operation.getNParms(); 
i++)
+                            for (unsigned int i = firstParm; i < 
operation.getNParms(); i++)
                             {
-                                os << "param" << (i + 1) << "=";
-                                writeParameter(xmlHelper, os, 
operation.getParameter(i));
+                                Operation::Parameter param = 
operation.getParameter(i);
+
+                                if(param.hasName())
+                                {
+                                    os << param.getName() << "=";
+                                }
+                                else
+                                {
+                                    // No name - use "param1", etc
+                                    os << "param" << (i + 1) << "=";
+                                }
+                                writeParameter(xmlHelper, os, param);
                                 if (i < operation.getNParms()-1)
                                     os << "&";
                             }
@@ -606,7 +636,7 @@
                             // Add the parameters in the form
                             // value1 / value2 / value3 
                             os << uri;
-                            for (int i = firstParm; i < operation.getNParms(); 
i++)
+                            for (unsigned int i = firstParm; i < 
operation.getNParms(); i++)
                             {
                                 os << "/";
                                 writeParameter(xmlHelper, os, 
operation.getParameter(i));
@@ -674,7 +704,7 @@
                     // If the request contains complex content then we'll use
                     // a POST, otherwise we use a GET with a query string
                     bool complexContent = false; 
-                    for (int i=0; i<operation.getNParms(); i++)
+                    for (unsigned int i=0; i<operation.getNParms(); i++)
                     {
                         if (operation.getParameter(i).getType() == 
Operation::DATAOBJECT)
                         {
@@ -724,13 +754,23 @@
     
                             // Multiple parameters, use a form type POST
                             struct curl_httppost *lastptr = NULL;
-                            for (int i=0; i<operation.getNParms(); i++)
+                            for (unsigned int i=0; i<operation.getNParms(); 
i++)
                             {
                                 ostringstream pname;
-                                pname << "param" << (i+1);
+                                Operation::Parameter param = 
operation.getParameter(i);
+
+                                if(param.hasName())
+                                {
+                                    pname << param.getName();
+                                }
+                                else
+                                {
+                                    // No name - use "param1", etc
+                                    pname << "param" << (i+1);
+                                }                                
                                 
                                 const char* ctype;
-                                if (operation.getParameter(i).getType() == 
Operation::DATAOBJECT)
+                                if (param.getType() == Operation::DATAOBJECT)
                                 {
                                     ctype ="text/xml"; 
                                 }
@@ -740,7 +780,7 @@
                                 }
                                 
                                 ostringstream pvalue;
-                                writeParameter(xmlHelper, pvalue, 
operation.getParameter(i));
+                                writeParameter(xmlHelper, pvalue, param);
                                 
                                 curl_formadd(&formpost,
                                     &lastptr,
@@ -764,17 +804,28 @@
     
                         // Add the parameters to the end of the URL in the form
                         // param=value&
-                        for (int i=0; i<operation.getNParms(); i++)
+                        for (unsigned int i=0; i<operation.getNParms(); i++)
                         {
                             if (i == 0)
                                 os << "?";
-                            os << "param" << (i + 1) << "=";
-                            writeParameter(xmlHelper, os, 
operation.getParameter(i));
+                            
+                            Operation::Parameter param = 
operation.getParameter(i);
+                            if(param.hasName())
+                            {
+                                os << param.getName() << "=";
+                            }
+                            else
+                            {
+                                // No name - use "param1", etc
+                                os << "param" << (i + 1) << "=";
+                            }
+                            writeParameter(xmlHelper, os, param);
                             if (i < operation.getNParms()-1)
                                 os << "&";
                         }
     
                         url = os.str();
+                        loginfo("RESTServiceWrapper: HTTP GET %s", 
url.c_str());
                                                                 
                         curl_easy_setopt(curl_handle, CURLOPT_URL, 
url.c_str());
                     }
@@ -790,10 +841,12 @@
                     {
                         curl_easy_setopt(curl_handle, CURLOPT_HTTPHEADER, 
requestHeaders);
                     }
-                                                
+                    
+                    loginfo("RESTServiceWrapper: Performing HTTP request");
                     // Perform the HTTP request
                     CURLcode rc = curl_easy_perform(curl_handle);
 
+                    loginfo("RESTServiceWrapper: Completed HTTP request");
                     // Free any headers
                     if (requestHeaders)
                     {
@@ -815,6 +868,9 @@
                     {
                         string responsePayload((const 
char*)responseChunk.memory, responseChunk.size);
                         
+
+                        loginfo("RESTServiceWrapper: responsePayload: %s", 
responsePayload.c_str());
+
                         //TODO Remove this workaround once SDO supports 
loading of open top level content
                         // The workaround is to wrap the open content in a 
wrapper element
                         string xmldecl;
@@ -1103,7 +1159,7 @@
                          */
                         DataObjectList& dataObjectList = 
outputDataObject->getList(pl[i]);
                         
-                        for(int j=0; j<dataObjectList.size(); j++)
+                        for(unsigned int j=0; j<dataObjectList.size(); j++)
                         {
                             DataObjectPtr dob = dataObjectList[j];
                             if(!dob)



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to