def allowObject(self, obj: Any) -> bool:
| 338 | |
| 339 | // def allowObject(self, obj: Any) -> bool: |
| 340 | PyObject* GroupExtensionPy::allowObject(PyObject* args) |
| 341 | { |
| 342 | PyObject* object; |
| 343 | if (!PyArg_ParseTuple(args, "O!", &(DocumentObjectPy::Type), &object)) { |
| 344 | return nullptr; |
| 345 | } |
| 346 | |
| 347 | auto* docObj = static_cast<DocumentObjectPy*>(object); |
| 348 | if (!docObj->getDocumentObjectPtr() |
| 349 | || !docObj->getDocumentObjectPtr()->isAttachedToDocument()) { |
| 350 | PyErr_SetString(Base::PyExc_FC_GeneralError, "Cannot check an invalid object"); |
| 351 | return nullptr; |
| 352 | } |
| 353 | if (docObj->getDocumentObjectPtr()->getDocument() |
| 354 | != getGroupExtensionPtr()->getExtendedObject()->getDocument()) { |
| 355 | PyErr_SetString(Base::PyExc_FC_GeneralError, |
| 356 | "Cannot check an object from another document from this group"); |
| 357 | return nullptr; |
| 358 | } |
| 359 | |
| 360 | GroupExtension* grp = getGroupExtensionPtr(); |
| 361 | |
| 362 | bool allowed = grp->allowObject(docObj->getDocumentObjectPtr()); |
| 363 | return PyBool_FromLong(allowed ? 1 : 0); |
| 364 | } |
no test coverage detected