[python-win32] Re-registering python COM servers

Mark Hammond mhammond at skippinet.com.au
Mon May 5 11:23:13 EDT 2003


> I'm writing some python COM server code, but have found that I have to
> change the actual filename and progID of the code every time 
> I register
> it for the client code (VB in this case) to see the changes I 
> make. I've
> tried un-registering first before registering, but that does not help.
> Is there any way I can edit my python COM server code and have the
> changes accessible to the client without having to change the name of
> the source file?

Actually, this is a standard Python optimization.

When an external program uses a COM object, a Python class is instantiated
from a module (as you know).  If ever that same process attempts to
re-import that same module (to create another COM object), Python caches the
import.  You already see this in all your Python programs - no matter how
many "import whatever" statements exist, it is only truly imported once, and
to see changes to a module in a running Python program, you need to "reload"
that module.

Somehow you need to either shutdown the process, or arrange for your module
to be "reloaded".  One way of doing a reload is to create a
Python.Interpreter COM object (one of the win32com demos), and ask it to
exec "import yourmod;reload(yourmod)".

I agree it would be nice to have win32com handle this magically, but I am
not sure how to expose this.

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


More information about the Python-win32 mailing list