#include <iostream>
#include <boost/python.hpp>
#include "Publisher.hh"
+#include <QDesktopServices>
//#include "PythonPublisher.mpp"
#define prefix_
Publisher * pythonPublisher;
};
+#define PYTHON_EXTERN_MODULE(module) \
+ extern "C" { void init ## module (); }
#define PYTHON_PREPARE_IMPORT(module) \
PyImport_AppendInittab(const_cast<char*>(#module), init ## module)
py::class_<PublisherPyWrapper, boost::noncopyable>("Publisher")
.def("publish", py::pure_virtual(&pykit::Publisher::publish))
;
+
+ py::def("openUrl", &QDesktopServices::openUrl);
}
+PYTHON_EXTERN_MODULE(_httpapi);
+
prefix_ pykit::PythonPublisher::PythonPublisher()
: impl_ (new Impl)
{
try {
PYTHON_PREPARE_IMPORT(_pykit);
PYTHON_PREPARE_IMPORT(_qt);
+ PYTHON_PREPARE_IMPORT(_httpapi);
Py_Initialize();
py::object initModule = py::import("init");
impl_->mainNamespace = py::extract<py::dict>(initModule.attr("__dict__"));
}
prefix_ pykit::PythonPublisher::~PythonPublisher()
-{}
+{
+ try {
+ impl_->mainNamespace["shutdown"]();
+ }
+ catch (...) {;}
+}
prefix_ void pykit::PythonPublisher::publish(Request & request)
{