From: Stefan Bund Date: Mon, 15 Nov 2010 15:16:32 +0000 (+0100) Subject: Fix PDF content type, better publisher initialization X-Git-Url: http://g0dil.de/git?a=commitdiff_plain;h=fb8a1722b7e8dc898284b9faa26754336775cba3;p=pykit.git Fix PDF content type, better publisher initialization --- diff --git a/PythonPublisher.cc b/PythonPublisher.cc index 56d7bc4..d71cdee 100644 --- a/PythonPublisher.cc +++ b/PythonPublisher.cc @@ -431,19 +431,16 @@ BOOST_PYTHON_MODULE(_pykit) ; } -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(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(impl_->mainNamespace["publisher"]); + py::object initModule = py::import("init"); + impl_->mainNamespace = py::extract(initModule.attr("__dict__")); + impl_->pythonPublisher = py::extract(impl_->mainNamespace["initialize"]()); } catch (boost::python::error_already_set & ex) { PyErr_Print(); diff --git a/PythonPublisher.hh b/PythonPublisher.hh index b6b6a5e..1065a38 100644 --- a/PythonPublisher.hh +++ b/PythonPublisher.hh @@ -22,7 +22,7 @@ namespace pykit { : public Publisher { public: - explicit PythonPublisher(std::string initPy); + explicit PythonPublisher(); ~PythonPublisher(); void publish(Request & request); diff --git a/Viewer.cc b/Viewer.cc index e16ffec..c9101ee 100644 --- a/Viewer.cc +++ b/Viewer.cc @@ -52,7 +52,7 @@ prefix_ QObject * PDFWebPluginFactory::create(QString const & mimeType, QUrl con 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; @@ -71,7 +71,7 @@ prefix_ QList PDFWebPluginFactory::plugins() plugin.description = "View PDF files"; { QWebPluginFactory::MimeType mimeType; - mimeType.name = "application/x-pdf"; + mimeType.name = "application/pdf"; mimeType.description = "PDF file"; plugin.mimeTypes += mimeType; } diff --git a/main.cc b/main.cc index 023e143..d83af4a 100644 --- a/main.cc +++ b/main.cc @@ -69,7 +69,7 @@ int main(int argc, char *argv[]) settings.beginGroup("Viewer"); - pykit::PythonPublisher publisher (settings.value("init").toString().toStdString()); + pykit::PythonPublisher publisher; QString url (settings.value("home").toString()); if (arguments.size()>1)