[glom] Python: Use gi.repository.Gda instead of Gda.
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glom] Python: Use gi.repository.Gda instead of Gda.
- Date: Tue, 5 Apr 2011 13:32:45 +0000 (UTC)
commit 58415583bba1dc8972db72c9cfb6962f59a49445
Author: Murray Cumming <murrayc murrayc com>
Date: Tue Apr 5 15:32:23 2011 +0200
Python: Use gi.repository.Gda instead of Gda.
* configure.ac: Do not require pygda at build time, though we check for it
at program startup. There is probably no similar way to check at configure
time, and it's debatable that it's appropriate anyway. The pygda check
was probably here before in order to use a pygda .h file that we no longer
use.
* glom/main.cc: Add and call check_gir_is_available_with_warning() to check
that gi.repository (gobject intropsection) in general is available.
* glom/python_embed/glom_python.[h|cc]:
* tests/test_python_module.[h|cc]: Add gir_python_module_is_available() for
use by main.cc.
gda_python_module_is_available(), glom_python_call(): Use the new python
module instead of the old Gda module.
ChangeLog | 17 +++++++++++++++++
configure.ac | 2 +-
glom/main.cc | 24 ++++++++++++++++++++++--
glom/python_embed/glom_python.cc | 14 +++++++++++---
glom/python_embed/glom_python.h | 5 +++++
tests/test_python_module.cc | 4 +++-
6 files changed, 59 insertions(+), 7 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index f5a10bf..e249748 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,22 @@
2011-04-05 Murray Cumming <murrayc murrayc com>
+ Python: Use gi.repository.Gda instead of Gda.
+
+ * configure.ac: Do not require pygda at build time, though we check for it
+ at program startup. There is probably no similar way to check at configure
+ time, and it's debatable that it's appropriate anyway. The pygda check
+ was probably here before in order to use a pygda .h file that we no longer
+ use.
+ * glom/main.cc: Add and call check_gir_is_available_with_warning() to check
+ that gi.repository (gobject intropsection) in general is available.
+ * glom/python_embed/glom_python.[h|cc]:
+ * tests/test_python_module.[h|cc]: Add gir_python_module_is_available() for
+ use by main.cc.
+ gda_python_module_is_available(), glom_python_call(): Use the new python
+ module instead of the old Gda module.
+
+2011-04-05 Murray Cumming <murrayc murrayc com>
+
Write Python tracebacks to stderr.
* glom/application.cc:
diff --git a/configure.ac b/configure.ac
index 1302436..bea5eb5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -154,7 +154,7 @@ AC_ARG_ENABLE([maemo-launcher],
[glom_maemo_launcher=no])
# Libraries used by libglom:
-REQUIRED_LIBGLOM_LIBS='gthread-2.0 giomm-2.4 libxml++-2.6 >= 2.23.1 pygda-4.0 >= 2.25.3 pygobject-2.0 >= 2.6.0 libgdamm-5.0 >= 4.99.0 libgda-postgres-5.0'
+REQUIRED_LIBGLOM_LIBS='gthread-2.0 giomm-2.4 libxml++-2.6 >= 2.23.1 pygobject-2.0 >= 2.6.0 libgdamm-5.0 >= 4.99.0 libgda-postgres-5.0'
AS_IF([test "x$glom_host_win32" != xyes],
[REQUIRED_LIBGLOM_LIBS="$REQUIRED_LIBGLOM_LIBS libepc-1.0 >= 0.3.1"])
diff --git a/glom/main.cc b/glom/main.cc
index 72e89cb..aba449c 100644
--- a/glom/main.cc
+++ b/glom/main.cc
@@ -356,16 +356,36 @@ bool check_pyglom_is_available_with_warning()
return false;
}
+bool check_gir_is_available_with_warning()
+{
+ if(gir_python_module_is_available())
+ return true;
+
+ /* The python module could not be imported by Glom, so warn the user: */
+ const Glib::ustring message = _("Your installation of Glom is not complete, because the gi.repository Python module is not available on your system.\n\nPlease report this bug to your vendor, or your system administrator so it can be corrected.");
+
+#ifndef GLOM_ENABLE_MAEMO
+ Gtk::MessageDialog dialog(Utils::bold_message(_("gi.repository Python Module Not Installed")), true /* use_markup */, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true /* modal */);
+ dialog.set_secondary_text(message);
+ dialog.run();
+#else
+ Hildon::Note note(Hildon::NOTE_TYPE_INFORMATION, message);
+ note.run();
+#endif //GLOM_ENABLE_MAEMO
+
+ return false;
+}
+
bool check_pygda_is_available_with_warning()
{
if(gda_python_module_is_available())
return true;
/* The python module could not be imported by Glom, so warn the user: */
- const Glib::ustring message = _("Your installation of Glom is not complete, because the gda Python module is not available on your system.\n\nPlease report this bug to your vendor, or your system administrator so it can be corrected.");
+ const Glib::ustring message = _("Your installation of Glom is not complete, because the gi.repository.Gda python module is not available on your system.\n\nPlease report this bug to your vendor, or your system administrator so it can be corrected.");
#ifndef GLOM_ENABLE_MAEMO
- Gtk::MessageDialog dialog(Utils::bold_message(_("gda Python Module Not Installed")), true /* use_markup */, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true /* modal */);
+ Gtk::MessageDialog dialog(Utils::bold_message(_("gi.repository.Gda Python Module Not Installed")), true /* use_markup */, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true /* modal */);
dialog.set_secondary_text(message);
dialog.run();
#else
diff --git a/glom/python_embed/glom_python.cc b/glom/python_embed/glom_python.cc
index 4f86202..5ae12b7 100644
--- a/glom/python_embed/glom_python.cc
+++ b/glom/python_embed/glom_python.cc
@@ -174,9 +174,16 @@ bool glom_python_module_is_available()
return module_glom != boost::python::object();
}
+bool gir_python_module_is_available()
+{
+ const char* name = "gi.repository";
+ const boost::python::object module_glom = import_module(name);
+ return module_glom != boost::python::object();
+}
+
bool gda_python_module_is_available()
{
- const char* name = "gda";
+ const char* name = "gi.repository.Gda";
const boost::python::object module_glom = import_module(name);
return module_glom != boost::python::object();
}
@@ -219,7 +226,7 @@ static boost::python::object glom_python_call(Field::glom_field_type result_type
else
func_signature = func_name + "(record, ui)";
- func_def = "def " + func_signature + ":\n import glom_" GLOM_ABI_VERSION_UNDERLINED "\n import gda\n" + func_def;
+ func_def = "def " + func_signature + ":\n import glom_" GLOM_ABI_VERSION_UNDERLINED "\n from gi.repository import Gda\n" + func_def;
//We did this in main(): Py_Initialize();
@@ -271,7 +278,7 @@ static boost::python::object glom_python_call(Field::glom_field_type result_type
}
//TODO: Is this necessary?
- boost::python::object module_gda = import_module("gda");
+ boost::python::object module_gda = import_module("gi.repository.Gda");
if(module_gda == boost::python::object())
{
g_warning("Could not import python gda module.");
@@ -360,6 +367,7 @@ static boost::python::object glom_python_call(Field::glom_field_type result_type
{
std::cerr << "Glom: Exception caught from pFunc(objRecord). func_name=" << std::endl << func_name << std::endl;
error_message = get_traceback();
+ //std::cerr << " traceback=" << error_message << std::endl;
}
if(!(pyResultCpp.ptr()))
diff --git a/glom/python_embed/glom_python.h b/glom/python_embed/glom_python.h
index 445e33d..683bb58 100644
--- a/glom/python_embed/glom_python.h
+++ b/glom/python_embed/glom_python.h
@@ -34,6 +34,11 @@ namespace Glom
*/
bool glom_python_module_is_available();
+/** Check that Python can really import the gi.repository module,
+ * as a runtime sanity check.
+ */
+bool gir_python_module_is_available();
+
/** Check that Python can really import the gda module,
* as a runtime sanity check.
*/
diff --git a/tests/test_python_module.cc b/tests/test_python_module.cc
index 0240097..19bb685 100644
--- a/tests/test_python_module.cc
+++ b/tests/test_python_module.cc
@@ -26,7 +26,9 @@ bool glom_python_module_is_available()
bool gda_python_module_is_available()
{
- const gchar* name = "gda";
+ //Python code usually uses "from gi.repository import Gda" so that
+ //the code may use Gda. rather than gi.repository.Gda in the code.
+ const gchar* name = "gi.repository.Gda";
PyObject* module_glom = PyImport_ImportModule((char*)name); //TODO: unref this?
if(!module_glom)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]