[glom/boostpythonretry] More apparent correctness



commit 3ffcc4f0bac1116122027cd9d6142cc64d4eac4f
Author: Murray Cumming <murrayc murrayc com>
Date:   Sat Feb 6 21:19:48 2010 +0100

    More apparent correctness

 glom/libglom/python_embed/py_glom_record.cc  |   12 +++++++-----
 glom/libglom/python_embed/py_glom_related.cc |    4 ----
 2 files changed, 7 insertions(+), 9 deletions(-)
---
diff --git a/glom/libglom/python_embed/py_glom_record.cc b/glom/libglom/python_embed/py_glom_record.cc
index 8776fde..10b2460 100644
--- a/glom/libglom/python_embed/py_glom_record.cc
+++ b/glom/libglom/python_embed/py_glom_record.cc
@@ -81,11 +81,13 @@ boost::python::object PyGlomRecord::get_related()
         map_relationships[(*iter)->get_name()] = *iter;
     }
 
-    PyObject* cobject = m_related.ptr();
-    PyGlomRelated* related_cpp = (PyGlomRelated*)(cobject); //TODO: Almost certainly wrong.
-    PyGlomRelated_SetRelationships(related_cpp, map_relationships);
-
-    related_cpp->m_record = boost::python::object(this); //TODO_NotSure
+    boost::python::extract<PyGlomRelated*> extractor(m_related);
+    if(extractor.check())
+    {
+      PyGlomRelated* related_cpp = extractor;
+      PyGlomRelated_SetRelationships(related_cpp, map_relationships);
+      related_cpp->m_record = boost::python::object(this); //TODO_NotSure
+    }
   }
 
   return m_related;
diff --git a/glom/libglom/python_embed/py_glom_related.cc b/glom/libglom/python_embed/py_glom_related.cc
index bd0a9ea..24f9258 100644
--- a/glom/libglom/python_embed/py_glom_related.cc
+++ b/glom/libglom/python_embed/py_glom_related.cc
@@ -18,9 +18,6 @@
  * Boston, MA 02111-1307, USA.
  */
 
-//We need to include this before anything else, to avoid redefinitions:
-//#include <Python.h>
-
 #include <libglom/python_embed/py_glom_related.h>
 //#include <libglom/python_embed/py_glom_record.h>
 #include <libglom/python_embed/py_glom_relatedrecord.h>
@@ -78,7 +75,6 @@ boost::python::object PyGlomRelated::getitem(boost::python::object cppitem)
           sharedptr<Relationship> relationship = iterFind->second;
           const Glib::ustring from_key = relationship->get_from_field();
           
-          //TODO: Wrong? Use ptr()?
           boost::python::extract<PyGlomRecord*> extractor(m_record);
           if(extractor.check())
           {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]