PropertyContainerPy: modified getPropertyByName()
Add 'checkOwner' argument to allow caller distinguish linked property
This commit is contained in:
@@ -16,7 +16,18 @@
|
||||
</Documentation>
|
||||
<Methode Name="getPropertyByName">
|
||||
<Documentation>
|
||||
<UserDocu>Return the value of a named property.</UserDocu>
|
||||
<UserDocu>
|
||||
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)
|
||||
</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="getPropertyTouchList">
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user