You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by aj...@apache.org on 2006/09/03 14:05:55 UTC

svn commit: r439766 - in /incubator/tuscany/cpp/sca/runtime/extensions/python/src/tuscany/sca/python: PythonServiceWrapper.cpp PythonServiceWrapper.h

Author: ajborley
Date: Sun Sep  3 05:05:54 2006
New Revision: 439766

URL: http://svn.apache.org/viewvc?rev=439766&view=rev
Log:
Fixed scoping error for module-only calls. Now will reload the module if scope is STATELESS

Modified:
    incubator/tuscany/cpp/sca/runtime/extensions/python/src/tuscany/sca/python/PythonServiceWrapper.cpp
    incubator/tuscany/cpp/sca/runtime/extensions/python/src/tuscany/sca/python/PythonServiceWrapper.h

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?rev=439766&r1=439765&r2=439766&view=diff
==============================================================================
--- 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 Sun Sep  3 05:05:54 2006
@@ -227,11 +227,25 @@
                 LOGENTRY(1,"PythonServiceWrapper::releaseInstance");
                 CPPInterface::SCOPE scope = interf->getScope();
 
-                if (scope == CPPInterface::STATELESS && pythonClassInstance != NULL && PyInstance_Check(pythonClassInstance))
+                if(scope == CPPInterface::STATELESS)
                 {
-                    Py_XDECREF(pythonClassInstance);
-                    pythonClassInstance = NULL;
-                }            
+                    // Delete the class instance if there is one
+                    if(pythonClassInstance != NULL && PyInstance_Check(pythonClassInstance))
+                    {
+                        Py_DECREF(pythonClassInstance);
+                        pythonClassInstance = NULL;
+                    }
+
+                    // Need to reload the module
+                    PyObject* reloadedPythonModule = PyImport_ReloadModule(pythonModule);
+
+                    if(reloadedPythonModule != NULL)
+                    {
+                        // Get rid of old pythonModule and replace with the reloaded one
+                        Py_DECREF(pythonModule);
+                        pythonModule = reloadedPythonModule;
+                    }
+                }
                 LOGEXIT(1,"PythonServiceWrapper::releaseInstance");
             }
             
@@ -250,12 +264,12 @@
                     LOGINFO_1(4, "PythonServiceWrapper::invoke called with operation name: %s", operation.getName().c_str());
 
                     PyObject* pFunc = NULL; 
-                    PyObject* pClassInstance = getInstance();
+                    pythonClassInstance = getInstance();
 
-                    if(pClassInstance != NULL && PyInstance_Check(pClassInstance))
+                    if(pythonClassInstance != NULL && PyInstance_Check(pythonClassInstance))
                     {
                         // Get the function from the instance
-                        pFunc = PyObject_GetAttrString(pClassInstance, (char*) operation.getName().c_str());
+                        pFunc = PyObject_GetAttrString(pythonClassInstance, (char*) operation.getName().c_str());
                     }
                     if(pFunc == NULL && pythonModule != NULL)
                     {

Modified: incubator/tuscany/cpp/sca/runtime/extensions/python/src/tuscany/sca/python/PythonServiceWrapper.h
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/extensions/python/src/tuscany/sca/python/PythonServiceWrapper.h?rev=439766&r1=439765&r2=439766&view=diff
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/extensions/python/src/tuscany/sca/python/PythonServiceWrapper.h (original)
+++ incubator/tuscany/cpp/sca/runtime/extensions/python/src/tuscany/sca/python/PythonServiceWrapper.h Sun Sep  3 05:05:54 2006
@@ -96,7 +96,7 @@
                 virtual PyObject* newInstance();
     
                 /**
-                 * Indicates that the current instance of the python class
+                 * Indicates that the current instance of the python module or class
                  * has been finished with. 
                  */
                 virtual void releaseInstance();



---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org