App: Expose allowObject for groups in python
This commit is contained in:
@@ -318,3 +318,30 @@ int GroupExtensionPy::setCustomAttributes(const char* /*attr*/, PyObject* /*obj*
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
// def allowObject(self, obj: Any) -> bool:
|
||||
PyObject* GroupExtensionPy::allowObject(PyObject* args)
|
||||
{
|
||||
PyObject* object;
|
||||
if (!PyArg_ParseTuple(args, "O!", &(DocumentObjectPy::Type), &object)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto* docObj = static_cast<DocumentObjectPy*>(object);
|
||||
if (!docObj->getDocumentObjectPtr()
|
||||
|| !docObj->getDocumentObjectPtr()->isAttachedToDocument()) {
|
||||
PyErr_SetString(Base::PyExc_FC_GeneralError, "Cannot check an invalid object");
|
||||
return nullptr;
|
||||
}
|
||||
if (docObj->getDocumentObjectPtr()->getDocument()
|
||||
!= getGroupExtensionPtr()->getExtendedObject()->getDocument()) {
|
||||
PyErr_SetString(Base::PyExc_FC_GeneralError,
|
||||
"Cannot check an object from another document from this group");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
GroupExtension* grp = getGroupExtensionPtr();
|
||||
|
||||
bool allowed = grp->allowObject(docObj->getDocumentObjectPtr());
|
||||
return PyBool_FromLong(allowed ? 1 : 0);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user