Boost logo

Boost :

From: yahoo_at_[hidden]
Date: 2001-08-30 14:56:54


Hi,
just tried to figure out this by myself and by reading the docs and
archives, but I failed:-(

Here is my problem.

I have an app which should
a) export objects to python and
b) embedds python.

I managed to build a extension module using boost, which builds
wrapper classes for my c++ objects.

In my App I include the extension dll to register my apps c++ objects
 
In the embedded python I load this extension module and get the
objects using the wrapped registry.

This works really fine. I can get access the apps objects from python
and change their attributes from there.

What I don't know is how I can create an PyObject* from one of my
classes to call a Python function with it? (embedded Python)

Code should like that:

#include "ext_mod.h"
int main(int, char**)
{
    Py_Initialize();
    CMyClass a; // create one of my apps class objects

    PyObject *pMod = PyImport_ImportModule("ext_mod"); // load the
extension module

    // now I need a PyObject Pointer for my object a
    PyObject* pA = ?????(a);

    // after that I would like to add it to the modules dict
    PyModule_AddObject(pMod,"a",pA);

    Py_Finalize();
}
    
How do I accomplish this?

In the definition for my ext_mod module (boost) I use
class_builder<CMyClass> myclass(mymod,"a");
to build an extension class. But how do I use this to call to_python
()?

How can I export this from my DLL if I have to use it to get my
PyObject* from CMyClass?

Thanks a lot
Joerg


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk