updating com server

Duncan Booth duncan at NOSPAMrcp.co.uk
Mon Aug 13 08:06:25 EDT 2001


jaspervp at hotmail.com (jasper) wrote in 
news:69b92f52.0108130242.5cbe4206 at posting.google.com:

> I have made a simple comserver with python which returns a string,
> when called from word.
> I have changed the comserver to return an other string, but it still
> returns the old string. I have tried unregistering and registering
> again, but that doesn't help. the only thing that seems to help is
> rebooting.
> 
> is there an easier way to do this?

In your COM server class, set the attribute:
 _reg_clsctx_ = pythoncom.CLSCTX_LOCAL_SERVER
This will ensure that your COM object always runs in a separate process: 
the default otherwise would be to run in the same process as the client.

Register your COM server then edit the registry CLSID\<your 
classid>\LocalServer32 to make python.exe the application to be run instead 
of pythonw.exe. (Alternatively I think that setting pythoncom.frozen=1 in 
your source file before registering may have the same effect.)

This will ensure that when your COM object is loaded it always runs in a 
new visible window. Now you can put print statements into your COM server 
to see what is happening, and when you edit the source you just need to 
remember to close the window to get rid of the old copy (most 
client applications should then restart the COM server when required).


-- 
Duncan Booth                                             duncan at rcp.co.uk
int month(char *p){return(124864/((p[0]+p[1]-p[2]&0x1f)+1)%12)["\5\x8\3"
"\6\7\xb\1\x9\xa\2\0\4"];} // Who said my code was obscure?



More information about the Python-list mailing list