[python-win32] COM server AddIn

Mark Hammond mhammond at skippinet.com.au
Wed Jul 6 01:31:50 CEST 2005


> This won't work! I can't start this COM server from my application.
> 
> First some questions: Do I have to write  _public_methods_ = 
> ['Init', 'Exit'] in order to satisfy the required interface 
> ICADdyAddIn?

No - but _public_methods_ must exist (ie, your code is fine)

> How do I handle the properties from ICADdyAddIn
> 	_prop_map_get_ = {
> 		"CLSID": (3, 2, (8, 0), (), "CLSID", None),
> 		"Description": (5, 2, (8, 0), (), "Description", None),
> 		"ProgId": (4, 2, (8, 0), (), "ProgId", None),
> 	}

IIRC you can either provide a simple attribute of that name, or a function
of that name for a "getter", and "Set{name}" as a setter.

eg, either:
  def __init__(self):
     ...
    self.Description = foo

or

  def Description(self):
       return "foo"

  def SetDescription(self, val):
      ...

FYI, that is implemented in win32com\server\policy.py

> correctly? Do have to use _public_attrs_ and if so how do I 
> use it correctly? 

I believe not.

> I used the methods getCLSID, getProgId and 
> getDescription
> just to give it a try but they seem to be totaly wrong.
> 
> I used the excelAddIn.py demo as a start. However, is this 
> the recommended way for writing a COM server addin?

Yep.

You need to know how to debug Python COM objects.  Basically:
* Register your object with "--debug" on the command-line.
* Start Pythonwin and select Tools->Remote Trace Collector
* Restart the app which creates the object.

You should see every COM call (including low-level ones, such as
QueryInterface), and you should also see any exceptions generated by your
object.  This is likely to give you a much better insight into what is
happening.

Mark
-------------- next part --------------
A non-text attachment was scrubbed...
Name: winmail.dat
Type: application/ms-tnef
Size: 2540 bytes
Desc: not available
Url : http://mail.python.org/pipermail/python-win32/attachments/20050706/ceec2445/winmail.bin


More information about the Python-win32 mailing list