;
}
-prefix_ pykit::PythonPublisher::PythonPublisher(std::string initPy)
+prefix_ pykit::PythonPublisher::PythonPublisher()
: impl_ (new Impl)
{
try {
PYTHON_PREPARE_IMPORT(_pykit);
PYTHON_PREPARE_IMPORT(_qt);
Py_Initialize();
- py::object mainModule_ = py::import("__main__");
- impl_->mainNamespace = py::extract<py::dict>(mainModule_.attr("__dict__"));
- impl_->mainNamespace["__file__"] = py::str(initPy.c_str());
- py::object ignored (
- py::exec_file(initPy.c_str(), impl_->mainNamespace, impl_->mainNamespace));
- impl_->pythonPublisher = py::extract<Publisher*>(impl_->mainNamespace["publisher"]);
+ py::object initModule = py::import("init");
+ impl_->mainNamespace = py::extract<py::dict>(initModule.attr("__dict__"));
+ impl_->pythonPublisher = py::extract<Publisher*>(impl_->mainNamespace["initialize"]());
}
catch (boost::python::error_already_set & ex) {
PyErr_Print();
: public Publisher
{
public:
- explicit PythonPublisher(std::string initPy);
+ explicit PythonPublisher();
~PythonPublisher();
void publish(Request & request);
QStringList const & /* argumentValues */)
const
{
- if (mimeType == "application/x-pdf") {
+ if (mimeType == "application/pdf") {
pykit::PDFWidget * plugin = new pykit::PDFWidget(manager_);
plugin->load(url);
return plugin;
plugin.description = "View PDF files";
{
QWebPluginFactory::MimeType mimeType;
- mimeType.name = "application/x-pdf";
+ mimeType.name = "application/pdf";
mimeType.description = "PDF file";
plugin.mimeTypes += mimeType;
}
settings.beginGroup("Viewer");
- pykit::PythonPublisher publisher (settings.value("init").toString().toStdString());
+ pykit::PythonPublisher publisher;
QString url (settings.value("home").toString());
if (arguments.size()>1)