[C++-sig] how t o specify and/or update global dictionary for bp::call call

Gennadiy Rozental rogeeff at gmail.com
Thu Sep 4 08:29:15 CEST 2008


Hi,

I've got class implemented in python, inherited from C++ class. I am using
wrapper/get_overload to invoke it's methods:

bp::override o = this->get_override( "update" );
bp::call< void >( o.ptr(), arg1, arg2 );

Now in update method I need to refer to the function foo that reside 
in module moo.

I've tried to add 
from moo import foo
and 
from moo import *

before class definition:

class MyPyDerivedClass( MyCPPBase ):
    def update( s, arg1, ARG2 ):
        foo()

Both attempts were futile. Looks like global dictionary during update call does
not contain foo.

So, now I am looking for a way for either update it somehow or specify my own.

Please advise.

Gennadiy

P.S. solution to add import method inside update method is unacceptable for
various (mostly political) reasons, though it obviously will work. I definitely
need this outside class definition

P.P.S. Instance of class MyPyDerivedClass is created on C++ side based on
pre-cached python type:

cpp_derived = m_py_type();







More information about the Cplusplus-sig mailing list