[C++-SIG] Trouble getting a method called

Steve Harris sharris at primus.com
Mon May 22 22:19:05 CEST 2000


"Barry Scott" <barry at scottb.demon.co.uk> writes:

> Here is a check list:
> 
> 1. init_type() must be static.

Check.


> 2. all the init_type() functions must be called from your modules
>    constructor [If not you will have no attributes]

==================================================
class seh_test_module : public Py::ExtensionModule<seh_test_module>
{
public:
	seh_test_module()
		: Py::ExtensionModule<seh_test_module>( "seh_test" )
	{
		py_bound_pod::init_type();

		add_varargs_method( "some_pod", &seh_test_module::new_py_bound_pod,
							"some_pod(str)" );

		initialize( "seh_test module explores wrapping a C++ POD in a Python type" );
	}
==================================================

Check.


> 3. from python do print dir(your_module) - check for all the module
>    attributes

>>> print dir( seh_test )
['__doc__', '__file__', '__name__','some_pod']

Okay.


> 4. from python do print dir(your_object) - check for all the object
>    attributes

>>> p = some_pod( "a string" )
Constructing some_pod( "a string" ): 0xd8c60
>>> print dir( p )
[]

Uh oh.


> 5. from python do print your_object.__methods__ - check for all your
>    methods

>>> print p.__methods__
Traceback (innermost last):
  File "<stdin>", line 1, in ?
RuntimeError: Extension object missing a required method.

Uh oh.


Anything else I can check?

-- 
Steven E. Harris
Primus Knowledge Solutions, Inc.
http://www.primus.com




More information about the Cplusplus-sig mailing list