| 27 | } |
| 28 | #define TEMPLATE_ATTR "template" |
| 29 | void PythonCreateContext::SetPythonObject(PyObject *ob) |
| 30 | { |
| 31 | ASSERT(ob); |
| 32 | m_PythonObject = ob; |
| 33 | Py_INCREF(m_PythonObject); |
| 34 | // now try and get the template object. |
| 35 | |
| 36 | if (ob!=Py_None) { |
| 37 | PyObject *pTempl = PyObject_GetAttrString(ob, TEMPLATE_ATTR); |
| 38 | if (pTempl==NULL) |
| 39 | PyErr_SetString(ui_module_error, "Warning - CreateContext object has no " TEMPLATE_ATTR " attribute"); |
| 40 | else { |
| 41 | m_pNewDocTemplate = PyCDocTemplate::GetTemplate(pTempl); |
| 42 | } |
| 43 | } |
| 44 | if (PyErr_Occurred()) |
| 45 | gui_print_error(); |
| 46 | } |
| 47 | void PythonCreateContext::ReleasePythonObject() |
| 48 | { |
| 49 | Py_XDECREF(m_PythonObject); |
no test coverage detected