473,395 Members | 1,891 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Python COM Server with C++

Hi,

I have written a Python COM Server with the help of Mark Hammond's
Book Programming Python on Win32. I used the CreateObjects method in
VB to access the COM Methods and all worked fine. Unfortunately, that
is not what i really want. First I'd like to make the COM Server
accessible from C++ and as a beside product I want to use early
binding within VB with the NEW operator. I've googled around alot, but
I still have not the complete picture of what to do.

So far I think I have to create an IDL file to describe the interface
and compile it with the MIDL Compiler. There ist my first question.
What do I have to create first, the IDL file or the Python COM Server?
I'm a little bit confused about dispid's, the GUID's and naming
conventions. Do i need to make use of the makepy Utility in any way?

Do I have to modify the Python COM Server Source Code in any way or
can I use it as it is? (I can post the code here on request)

It would be great if anybody can give me information about the things
i have to do in order to make this work. Documentation links and
sample code would also be fantastic.

(I'm programming on Python 2.2 with the appropriate Windows Extensions
and Visual C++ 6.0)

Thx in advance

Andre
Jul 18 '05 #1
5 2389
an*************@gmx.de (Andre Bernemann) writes:
I have written a Python COM Server with the help of Mark Hammond's
Book Programming Python on Win32. I used the CreateObjects method in
VB to access the COM Methods and all worked fine. Unfortunately, that
is not what i really want. First I'd like to make the COM Server
accessible from C++ and as a beside product I want to use early
I'd do this in ctypes, although its COM support is still quite new.
win32com (from win32all, aka Python for Windows Extensions, which is
what you're probably using ATM) has recently grown support for
implementing vtable interfaces (but not calling them, IIRC), but I
suspect one is less likely to get stuck when using ctypes, since
everything is pretty close to the way you'd do in in C (COM makes that
quite complicated, of course, but I think the ctypes COM support is
fairly 'thin' -- probably a good thing, IMHO -- but also elegant).

binding within VB with the NEW operator. I've googled around alot, but
I still have not the complete picture of what to do.
Take at look at win32/com/samples/server in the ctypes package -- an
example of implementing a dual interface. I haven't tried a dual
interface myself, but, as COM goes, it all looks very simple and
elegant.

So far I think I have to create an IDL file to describe the interface
and compile it with the MIDL Compiler. There ist my first question.
What do I have to create first, the IDL file or the Python COM Server?
IDL first. This is explained in the little comment at the top of the
sample.

I'm a little bit confused about dispid's, the GUID's and naming
conventions. Do i need to make use of the makepy Utility in any way?
I don't know how one implements vtable/dual interfaces in win32com.

Do I have to modify the Python COM Server Source Code in any way or
can I use it as it is? (I can post the code here on request)

[...]

ditto
John
Jul 18 '05 #2
an*************@gmx.de (Andre Bernemann) writes:
I have written a Python COM Server with the help of Mark Hammond's
Book Programming Python on Win32. I used the CreateObjects method in
VB to access the COM Methods and all worked fine. Unfortunately, that

[...]

Hmm, sorry, I didn't really read the question properly!

If you've started with win32all, you probably want to stick with it.
I'd guess the python-win32 list is more likely to yield answers
(though Mark has been posting here recently, so you might be
lucky...). Make sure to search the list archive first, of course.
John
Jul 18 '05 #3
an*************@gmx.de (Andre Bernemann) writes:
Hi,

I have written a Python COM Server with the help of Mark Hammond's
Book Programming Python on Win32. I used the CreateObjects method in
VB to access the COM Methods and all worked fine. Unfortunately, that
is not what i really want. First I'd like to make the COM Server
accessible from C++ and as a beside product I want to use early
binding within VB with the NEW operator. I've googled around alot, but
I still have not the complete picture of what to do.

So far I think I have to create an IDL file to describe the interface
and compile it with the MIDL Compiler. There ist my first question.
What do I have to create first, the IDL file or the Python COM Server?
I'm a little bit confused about dispid's, the GUID's and naming
conventions. Do i need to make use of the makepy Utility in any way?


I think you should create the typelib first, and then write a com object
implementing the interfaces.

I don't have done it myself, but I suggest to look into the spambayes
project. It contains an outlook plugin, written by Mark Hammond.
Most certainly a bag full of ideas.

Thomas
Jul 18 '05 #4
Thomas Heller <th*****@python.net> writes:
an*************@gmx.de (Andre Bernemann) writes: [...] I think you should create the typelib first, and then write a com object
implementing the interfaces.

I don't have done it myself, but I suggest to look into the spambayes
project. It contains an outlook plugin, written by Mark Hammond.
Most certainly a bag full of ideas.


There's a cut down to bare-bones version of this in the win32all
package.

I wasn't able to get it working with the problem I tried, though (in
contrast to ctypes). I didn't try too hard, though, I admit ;-)
John
Jul 18 '05 #5
Thank you very much for the help, I got it working with ctypes.

Cheers
André
Jul 18 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: DeepBleu | last post by:
When one is using an HTML form via a web broswer, the user submits the form contents and these are passed to a CGI Python script on the web server. I need to write a client script that connects to...
19
by: Jane Austine | last post by:
As far as I know python's threading module models after Java's. However, I can't find something equivalent to Java's interrupt and isInterrupted methods, along with InterruptedException....
0
by: Phillip J. Eby | last post by:
PEP: 333 Title: Python Web Server Gateway Interface v1.0 Version: $Revision: 1.1 $ Last-Modified: $Date: 2004/08/27 17:30:09 $ Author: Phillip J. Eby <pje at telecommunity.com> Discussions-To:...
10
by: Andrew Dalke | last post by:
Is there an author index for the new version of the Python cookbook? As a contributor I got my comp version delivered today and my ego wanted some gratification. I couldn't find my entries. ...
47
by: Kenneth McDonald | last post by:
Is there any emerging consensus on the "best" UI for toolkit. Tk never quite made it but from what I can see, both qt and wxWin are both doing fairly well in general. I'm already aware of the...
13
by: John Salerno | last post by:
I'm hoping someone can give me the basics for how to do very simple things with Python scripts from within my HTML. For example, I know that I can do this in PHP: <h1>Here is a header</h1>...
28
by: H J van Rooyen | last post by:
Hi, I want to write a small system that is transaction based. I want to split the GUI front end data entry away from the file handling and record keeping. Now it seems almost trivially easy...
15
by: John Nagle | last post by:
I've been installing Python and its supporting packages on a dedicated server with Fedora Core 6 for about a day now. This is a standard dedicated rackmount server in a colocation facility,...
5
by: walterbyrd | last post by:
I don't know much php either, but running a php app seems straight forward enough. Python seems to always use some sort of development environment vs production environment scheme. For...
0
by: GeicoGecko | last post by:
Hey guys, There was no python section in the "Web Development" forum so I'm hoping I can pose my question in here. Our system We currently have a python webserver using SimpleHTTPServer,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.