expose recompute() of document object to Python

This commit is contained in:
wmayer
2016-11-19 16:24:11 +01:00
parent acec8d0385
commit 01065b76d5
5 changed files with 43 additions and 19 deletions

View File

@@ -51,6 +51,10 @@ FeaturePythonImp::~FeaturePythonImp()
*/
bool FeaturePythonImp::execute()
{
// avoid recursive calls of execute()
if (object->testStatus(App::PythonCall))
return false;
// Run the execute method of the proxy object.
Base::PyGILStateLocker lock;
try {
@@ -59,6 +63,7 @@ bool FeaturePythonImp::execute()
Py::Object feature = static_cast<PropertyPythonObject*>(proxy)->getValue();
if (feature.hasAttr(std::string("execute"))) {
if (feature.hasAttr("__object__")) {
ObjectStatusLocker exe(App::PythonCall, object);
Py::Callable method(feature.getAttr(std::string("execute")));
Py::Tuple args;
Py::Object res = method.apply(args);
@@ -67,6 +72,7 @@ bool FeaturePythonImp::execute()
return true;
}
else {
ObjectStatusLocker exe(App::PythonCall, object);
Py::Callable method(feature.getAttr(std::string("execute")));
Py::Tuple args(1);
args.setItem(0, Py::Object(object->getPyObject(), true));