Re: COM: Minimal example of a custom server working with DispatchWithEvents()

"[email protected]" <[email protected]>
Newsgroups gmane.comp.python.windows
Message-ID <[email protected]>
/Hi!/
/
/
/Druide-Antidote is not a server; it is a client, who connect to 
different servers (COM-servers), like Word, Excel, OpenOffice.org, etc.
/
/
/
/@-salutations
/
/--
/


Le 27/07/2021 à 23:58, William Belanger a écrit :
>
> Hi everyone,
>
> I'm trying to make a cross-platform Python interface for a third-party 
> API (Druide Antidote). The D-Bus part is done and working 
> (https://gitlab.com/-/snippets/2151173 
> <https://gitlab.com/-/snippets/2151173>), it consist of a server 
> adapter (AdaptateurAntidote), which relay the events to an handler 
> class (ImplementationAntidote).
>
> I want to do the same with the COM interface. However, I could not get 
> DispatchWithEvents() to work, as it fails on "ti = 
> disp._oleobj_.GetTypeInfo()";
>
>     C:\Users\user>"C:\Users\user\Desktop\AntidoteCOM.py -
>     Shortcut.lnk" --register
>
>     Requesting elevation and retrying...
>
>     Registered: Correcteur.Antidote
>
>     C:\Users\user>"C:\Users\user\Desktop\AntidoteCOM.py - Shortcut.lnk"
>
>     Traceback (most recent call last):
>
>     File
>     "C:\Users\user\AppData\Local\Programs\Python\Python38\lib\site-packages\win32com\client\__init__.py",
>     line 256, in DispatchWithEvents
>
>     ti = disp._oleobj_.GetTypeInfo()
>
>     pywintypes.com_error: (-2147352567, 'Exception occurred.', None, None)
>
>     During handling of the above exception, another exception occurred:
>
>     Traceback (most recent call last):
>
>     File "Z:\.antidote_\AntidoteCOM.py", line 54, in _connect
>
>     self.server =
>     win32com.client.DispatchWithEvents("Correcteur.Antidote",
>     EventHandler)
>
>     File
>     "C:\Users\user\AppData\Local\Programs\Python\Python38\lib\site-packages\win32com\client\__init__.py",
>     line 264, in DispatchWithEvents
>
>     raise TypeError("This COM object can not automate the makepy
>     process - please run makepy manually for this object")
>
>     TypeError: This COM object can not automate the makepy process -
>     please run makepy manually for this object
>
> I noticed that when running localserve.serve() in a separate console, 
> the server returns as DispatchWithEvents() is called. No errors are 
> thrown on the server side, but I assume there is something wrong or 
> missing in the class definition of AdaptateurAntidote. I tried 
> changing its policy to dynamic, but that did not help.
>
> *If someone could provide a minimal example of a custom server working 
> along with DispatchWithEvents(), that would be very helpful. *All the 
> examples I could find use third-party servers, such as those provided 
> by Microsoft.
>
> Full code available is here; https://gitlab.com/-/snippets/2154411 
> <https://gitlab.com/-/snippets/2154411>
>
> Will
>
>
> _______________________________________________
> python-win32 mailing list
> [email protected]
> https://mail.python.org/mailman/listinfo/python-win32

_______________________________________________
python-win32 mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-win32
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.