473,399 Members | 2,159 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,399 software developers and data experts.

Creating COM server Events?

Dan
I have need to create a com server that will fire events back to
clients. I have looked at some of the documentation and I am new to
Python so cant quite get it. I have created an IDL file of the
interfaces. Can someone tell me approximately what needs to be done
here. I have seen examples of implementing the regular interfaces but
don't know what to do about the events interfaces.The vid...Events
interface is the main question here. In regular com development you
would implement something along the lines of Fire_OnNewData(). My Com
developement has mostly been with Borland tools and they do quite a bit
for you, As I hope Python will. Heres the IDL:

[
uuid(B0ADD4E1-1793-4089-8298-20B5A2DB0E82),
version(1.0),
helpstring("vidVisPython Library")

]
library vidVisPython
{

importlib("stdole2.tlb");

[
uuid(E26E3023-4F65-4E3D-A900-56C6302CD4E0),
version(1.0),
dual,
oleautomation
]
interface IVideoVisitationPython: IDispatch
{
[
id(0x00000001)
]
HRESULT _stdcall AdviseNewData( void );
};

[
uuid(50A02634-215F-47C6-9749-CDD02DC99B13),
version(1.0)
]
dispinterface IVideoVisitationPythonEvents
{
properties:
methods:
[
id(0x00000001)
]
HRESULT OnNewData( void );
};

[
uuid(134821F5-35B9-4917-B6EE-EF5C508BE949),
version(1.0)
]
coclass CoVideoVisitationPython
{
[default] interface IVideoVisitationPython;
[default, source] dispinterface IVideoVisitationPythonEvents;
};

};

Mar 29 '06 #1
2 1293
Dan
Here is what little I have so far. I can use clients to call the advise
method and store in the mylist set (should be named myset i guess).
Now, I want the client to have to implement a callback and register the
interface in the AdviseChange method.

glcount=0
mylist= set()
class TestTTechPycom:
_public_methods_= ["AdviseChange","ShowTheList"]
_reg_progid_ = "TestTTechPycom"
_reg_clsid_ = "{D5BA19AA-0F4D-4022-A811-40C087FE089A}"

def AdviseChange(self):
if not self in mylist:
mylist.add(self)
print "added"
else:
print "already added"

def ShowTheList(self):
print mylist
if __name__=='__main__':
print "Registering TestTTechPycom server"
import win32com.server.register
win32com.server.register.UseCommandLine(TestTTechP ycom)

So, when I call the AdviseChange now, a unique ID is placed into
mylist. If you run ShowTheList()
it will give a different instance ID for each registered client. Great!
So given something like;

def AdviseChange(self,interfacepointer)
mylist.add(interfacepointer)
How do I define what the interface for the interfacepointer should look
like. I mean in my typelib listed in my previous post, the interface
for the events were marked as Source so that COM knows that the client
must implement them. How do you do that in Python? Dan

Mar 29 '06 #2
You'll need to implement the IConnectionPoint and
IConnectionPointContainer interfaces with your server.
See \win32com\demos\connect.py and
\win32com\server\connect.py for some sample code.

Roger

"Dan" <da*****@gmail.com> wrote in message news:11*********************@i40g2000cwc.googlegro ups.com...
I have need to create a com server that will fire events back to
clients. I have looked at some of the documentation and I am new to
Python so cant quite get it. I have created an IDL file of the
interfaces. Can someone tell me approximately what needs to be done
here. I have seen examples of implementing the regular interfaces but
don't know what to do about the events interfaces.The vid...Events
interface is the main question here. In regular com development you
would implement something along the lines of Fire_OnNewData(). My Com
developement has mostly been with Borland tools and they do quite a bit
for you, As I hope Python will. Heres the IDL:

[
uuid(B0ADD4E1-1793-4089-8298-20B5A2DB0E82),
version(1.0),
helpstring("vidVisPython Library")

]
library vidVisPython
{

importlib("stdole2.tlb");

[
uuid(E26E3023-4F65-4E3D-A900-56C6302CD4E0),
version(1.0),
dual,
oleautomation
]
interface IVideoVisitationPython: IDispatch
{
[
id(0x00000001)
]
HRESULT _stdcall AdviseNewData( void );
};

[
uuid(50A02634-215F-47C6-9749-CDD02DC99B13),
version(1.0)
]
dispinterface IVideoVisitationPythonEvents
{
properties:
methods:
[
id(0x00000001)
]
HRESULT OnNewData( void );
};

[
uuid(134821F5-35B9-4917-B6EE-EF5C508BE949),
version(1.0)
]
coclass CoVideoVisitationPython
{
[default] interface IVideoVisitationPython;
[default, source] dispinterface IVideoVisitationPythonEvents;
};

};



----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= East/West-Coast Server Farms - Total Privacy via Encryption =---
Mar 30 '06 #3

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

Similar topics

10
by: Dee | last post by:
Is C++ the best language to create a Windows based Instant Messenger? Something along the lines of MSN Messenger, ICQ, Yahoo Chat, etc? Are there any downloadable full or trial SDK's out there?...
2
by: Ben | last post by:
My current project requires me to create part of a form that is created on the fly. The project consists a list of entries to an event. The name and address and such is easy. The design is detup so...
9
by: Maziar Aflatoun | last post by:
Hi everyone, I like to export some data from the database and allow my users to store this file to their harddrive as a .txt file. Does anyone know how I would go about doing that? (without...
1
by: Ryan McLean | last post by:
Hi everyone! What is happening is the method: sub_btnSubmitClicked is being executed every time any other object with a Handler is executed. I am trying not to use the withevents and handles...
2
by: Steve Caliendo | last post by:
Hi, In the Page_Load sub, can someone tell me what code to place to create a pop-up window? Thanks, Steve
2
by: Patrick | last post by:
I want to define a set of web-form templates in XML and render the equivalent web-form with ASP.NET, then process any input server controls on the form. Reading the XML file from Page_load is...
12
by: Mats Lycken | last post by:
Hi, I'm creating a CMS that I would like to be plug-in based with different plugins handling different kinds of content. What I really want is to be able to load/unload plugins on the fly without...
0
by: emferrari | last post by:
Hi all I was going to start a new ASP.NET application yesterday. When I tryed to create it using the Microsoft Visual Studio.NET I got some messages that the application was unable to access the...
10
by: brooksr | last post by:
I know VB5/VBA very well but have not used VB to create web pages but need to do so. Can someone explain the purposes and differences between VBScript and VB.NET to create web pages? Also...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.