diff --git a/src/App/PropertyContainerPy.xml b/src/App/PropertyContainerPy.xml
index a1d79a8108..fbccd25258 100644
--- a/src/App/PropertyContainerPy.xml
+++ b/src/App/PropertyContainerPy.xml
@@ -16,7 +16,18 @@
- Return the value of a named property.
+
+getPropertyByName(name,checkOwner=0)
+
+Return the value of a named property. Note that the returned property may not
+always belong to this container (e.g. from a linked object).
+
+* name: name of the property
+* checkOwner: 0: just return the property
+ 1: raise exception if not found or the property
+ does not belong to this container
+ 2: return a tuple(owner,property_value)
+
diff --git a/src/App/PropertyContainerPyImp.cpp b/src/App/PropertyContainerPyImp.cpp
index a9c2b8ad9b..488abc52dd 100644
--- a/src/App/PropertyContainerPyImp.cpp
+++ b/src/App/PropertyContainerPyImp.cpp
@@ -54,16 +54,19 @@ std::string PropertyContainerPy::representation(void) const
PyObject* PropertyContainerPy::getPropertyByName(PyObject *args)
{
char *pstr;
- if (!PyArg_ParseTuple(args, "s", &pstr)) // convert args: Python->C
+ int checkOwner=0;
+ if (!PyArg_ParseTuple(args, "s|i", &pstr, &checkOwner)) // convert args: Python->C
return NULL; // NULL triggers exception
App::Property* prop = getPropertyContainerPtr()->getPropertyByName(pstr);
if (prop) {
- return prop->getPyObject();
- }
- else {
- PyErr_Format(PyExc_AttributeError, "Property container has no property '%s'", pstr);
- return NULL;
+ if(!checkOwner || (checkOwner==1 && prop->getContainer()==getPropertyContainerPtr()))
+ return prop->getPyObject();
+ Py::TupleN res(Py::asObject(prop->getContainer()->getPyObject()),
+ Py::asObject(prop->getPyObject()));
+ return Py::new_reference_to(res);
}
+ PyErr_Format(PyExc_AttributeError, "Property container has no property '%s'", pstr);
+ return NULL;
}
PyObject* PropertyContainerPy::getPropertyTouchList(PyObject *args)