Python embedding question: how to expose a new "builtin"?
Rodrigo B. de Oliveira
rodrigobamboo at hotmail.com
Tue Nov 19 11:07:51 EST 2002
I've built an ISAPI module that allows .py files to be executed by IIS,
everything is working fine and the performance is great. Now I want to
expose an object in such a way that every imported module could see it, I
tried the following code but it didn't quite work:
<snip language="C++">
PyObject* __builtin__ = PyImport_ImportModule("__builtin__");
PyObject_SetAttrString(__builtin__, "application", (PyObject*)_pyapplication);
Py_DECREF(__builtin__);
</snip>
Notes:
* _pyapplication is an instance of a C new style class
The problem is: the modules can see the name "application" but
dir(application) returns [] and if I try to access any of application's
attributes I get an AttributeError.
Thoughts?
Thanks in advance,
Rodrigo B. de Oliveira
PS: the ISAPI module will go Open Source in a few days...
More information about the Python-list
mailing list