I got the comserver working with Python clients (both pythoncom and comtypes) by inheriting from COMObject and waving typelib chickens in the air and setting _com_interfaces_. This involved reading the comtypes source code and looking at the debugging messages. I was unable to get it to work via the documented approach of subclassing from the python class code-generated from the type-library.
I got it working with Excel on one development machine but only after code-signing the _ctypes.pyd dll with a certificate that is a trusted publisher on that machine. See below for a theory as to why that worked. This has been a useful 'proof by construction' for me but it is still way too hacky for me to use at work. I will investigate into py2exe (it is amazing that Thomas Heller is the originator of three fiendishly useful packages such as py2exe, ctypes and comtypes) to package the recognizer as a DLL as I don't want a code-signed _ctypes.pyd laying around waiting for trouble-makers! pjjH class Action(comtypes.COMObject): _reg_threading_ = "Both" _reg_clsctx_ = CLSCTX_LOCAL_SERVER | CLSCTX_INPROC_SERVER _reg_clsid_ = "{5FCDCEC7-A951-4931-84A4-7A8CA3C9416F}" _reg_typelib_ = comtypes.gen.SmartTagLib.Library._reg_typelib_ # Note the underscores on the LHS but not on the RHS _typelib_path_ = comtypes.gen.SmartTagLib.typelib_path _com_interfaces_ = [ISmartTagAction] Note that the property names have '_get_' prepended to the property name. def _get_VerbCount(self, SmartTagName): 'The total number of verbs that are supported by the implementation for a given smart tag type.' logging.debug('VerbCount') return 1 This is the entry one has to make in HKCU to add the SmartTagAction to Excel's list. However, this did not work initially as my Excel is set up to trust only signed addins. I suspect that MOFL.DLL does its thing with creating the recognizer and action COM instances early on shortly after Excel starts up. If Excel is waiting for me to click around on the Message Bar to OK loading up possibly dodgy content, I imagine that MOFL.DLL has given up (silently) on initalizing that component and goes on about its business. As a joke, I signed a copy of the _ctypes.pyd file with a certificate that is a trusted publisher and -- rather amazingly -- the caption from my Python recognizer showed up in the additional actions menu and the debugging logs show the cell contents being passed correctly as a parameter to InvokeVerb. HKEY_CURRENT_USER\Software\Microsoft\Office\Common\Smart Tag\Actions\{5FCDCEC7-A951-4931-84A4-7A8CA3C9416F} ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ comtypes-users mailing list comtypes-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/comtypes-users