[python-win32] Yet another python-com bridge (wincom.pyd)

Lijun Qin qinlj at solidshare.com
Sat Mar 27 21:31:40 EST 2004


Hi all,

Here is my own python-com bridge (named wincom), which support Python at as
both server and client side, support C++ access python use vtable interface
when the interface is a dual interface (similar to universal_gateway featuer
of win32all).
One of the feature of wincom is that there is only a simple pyd file
(wincom.pyd, and runtime boost_python23.dll) to deply, unlike win32-all
package you'll need deploy a whole package.
Another feature of wincom is that it's use is quite simple, a typelib is in
the center, and all objects in the typelib can be easily imported, like
this:

import wincom
msxml = wincom.typelib('{F5078F18-C551-11D3-89B9-0000F81FE221}', 4, 0)

after these lines, all objects in the msxml4.0 typelib can be easily
accessed, like this:

self.dom = msxml.DOMDocument40()        #create a CoClass use it's name
if not self.dom.load(file_name):
            raise RuntimeError, "load xml file failed"

self.node = self.dom.documentElement        #COM object property mapped to
python attribute
self.id = self.node.getAttribute('id')             #COM object function
mapped to python method

self.my_objs = []
for my_obj_node in self.node.selectNodes("//my_obj"):    #COM enumratable
mapped to python iter object
    self.my_objs.append(my_obj_class(self, my_obj_node))

You can download the file from http://www.solidshare.com/python/wincom.pyd,
source file is not included, but if peoples like it, I'll consider setup a
project in sourceforge or somewhere else.

Lijun Qin




More information about the Python-win32 mailing list