DECLARE_EXPORT PyObject* readXMLfile(PyObject* self, PyObject* args) { // Pick up arguments char *filename = NULL; int validate(1), validate_only(0); PyObject *userexit = NULL; int ok = PyArg_ParseTuple(args, "|siiO:readXMLfile", &filename, &validate, &validate_only, &userexit); if (!ok) return NULL; // Execute and catch exceptions Py_BEGIN_ALLOW_THREADS // Free Python interpreter for other threads try { if (!filename) { // Read from standard input xercesc::StdInInputSource in; XMLInput p; if (userexit) p.setUserExit(userexit); if (validate_only!=0) // When no root object is passed, only the input validation happens p.parse(in, NULL, true); else p.parse(in, &Plan::instance(), validate!=0); } else { XMLInputFile p(filename); if (userexit) p.setUserExit(userexit); if (validate_only!=0) // Read and validate a file p.parse(NULL, true); else // Read, execute and optionally validate a file p.parse(&Plan::instance(),validate!=0); } } catch (...) { Py_BLOCK_THREADS; PythonType::evalException(); return NULL; } Py_END_ALLOW_THREADS // Reclaim Python interpreter return Py_BuildValue(""); }