| 428 | } |
| 429 | |
| 430 | void PropertyPythonObject::Save(Base::Writer& writer) const |
| 431 | { |
| 432 | std::string repr = this->toString(); |
| 433 | repr = Base::base64_encode((const unsigned char*)repr.c_str(), repr.size()); |
| 434 | std::string val = /*encodeValue*/ (repr); |
| 435 | writer.Stream() << writer.ind() << "<Python value=\"" << val << R"(" encoded="yes")"; |
| 436 | |
| 437 | Base::PyGILStateLocker lock; |
| 438 | try { |
| 439 | if (this->object.hasAttr("__module__") && this->object.hasAttr("__class__")) { |
| 440 | Py::String mod(this->object.getAttr("__module__")); |
| 441 | Py::Object cls(this->object.getAttr("__class__")); |
| 442 | if (cls.hasAttr("__name__")) { |
| 443 | Py::String name(cls.getAttr("__name__")); |
| 444 | writer.Stream() << " module=\"" << (std::string)mod << "\"" |
| 445 | << " class=\"" << (std::string)name << "\""; |
| 446 | } |
| 447 | } |
| 448 | else { |
| 449 | writer.Stream() << " json=\"yes\""; |
| 450 | } |
| 451 | } |
| 452 | catch (Py::Exception&) { |
| 453 | Base::PyException e; // extract the Python error text |
| 454 | e.reportException(); |
| 455 | } |
| 456 | |
| 457 | saveObject(writer); |
| 458 | writer.Stream() << "/>" << std::endl; |
| 459 | } |
| 460 | |
| 461 | void PropertyPythonObject::Restore(Base::XMLReader& reader) |
| 462 | { |
nothing calls this directly
no test coverage detected