Invoking Python COM server as 'local' server

Gregory P. Smith greg at electricrain.com
Thu May 31 15:01:35 EDT 2001


On Thu, May 31, 2001 at 01:17:37PM -0400, Bill Bell wrote:
> 
> To my understanding, one usually builds a local COM server as an 
> EXE. However, a Python COM server is neither a DLL nor an EXE; 
> it's a PY. So how the heck does the Python COM machinery 
> decide whether to create an in-process server or a local server, 
> particularly when the default _reg_clsctx provides for registration of 
> a server as both?
> 
> Put another way: Having built a Python COM server I would like to 
> build a Python COM client that fires it up as a local server.
> 
> And obviously I'm very confused. (TIA)

We wanted local server only (not in process) for our application as
well.  Here is what we did.  In our com server class that we use when
calling register(), make sure this attribute it set:

class MyCOMServer:
    # ...
    _reg_clsctx_ = pythoncom.CLSCTX_LOCAL_SERVER
    # ...

We also package our application (mojonation) up using py2exe, and have
the python registration code set "pythoncom.frozen = 1" before it
calls register() on installation so that the path to the actual .exe
is registered with the OS so it can be installed and run on systems
without python installed.

[I never found any docs describing those tricks in an obvious manner;
playing around and reading the win32com source code led to finding
that solution]

-- 
Gregory P. Smith   gnupg/pgp: http://electricrain.com/greg/keys/
                   C379 1F92 3703 52C9 87C4  BE58 6CDA DB87 105D 9163




More information about the Python-list mailing list