| 1081 | } |
| 1082 | |
| 1083 | int DocumentPy::setCustomAttributes(const char* attr, PyObject*) |
| 1084 | { |
| 1085 | // Note: Here we want to return only a document object if its |
| 1086 | // name matches 'attr'. However, it is possible to have an object |
| 1087 | // with the same name as an attribute. If so, we return 0 as other- |
| 1088 | // wise it wouldn't be possible to address this attribute any more. |
| 1089 | // The object must then be addressed by the getObject() method directly. |
| 1090 | App::Property* prop = getPropertyContainerPtr()->getPropertyByName(attr); |
| 1091 | if (prop) { |
| 1092 | return 0; |
| 1093 | } |
| 1094 | if (!this->ob_type->tp_dict) { |
| 1095 | if (PyType_Ready(this->ob_type) < 0) { |
| 1096 | return 0; |
| 1097 | } |
| 1098 | } |
| 1099 | PyObject* item = PyDict_GetItemString(this->ob_type->tp_dict, attr); |
| 1100 | if (item) { |
| 1101 | return 0; |
| 1102 | } |
| 1103 | DocumentObject* obj = getDocumentPtr()->getObject(attr); |
| 1104 | if (obj) { |
| 1105 | std::stringstream str; |
| 1106 | str << "'Document' object attribute '" << attr << "' must not be set this way" << std::ends; |
| 1107 | PyErr_SetString(PyExc_RuntimeError, str.str().c_str()); |
| 1108 | return -1; |
| 1109 | } |
| 1110 | |
| 1111 | return 0; |
| 1112 | } |
| 1113 | |
| 1114 | PyObject* DocumentPy::getLinksTo(PyObject* args) |
| 1115 | { |
nothing calls this directly
no test coverage detected