[python-win32] com servers and py2exe
Floris van Nee
floris.vannee at gmail.com
Mon Jun 26 15:52:01 CEST 2006
Ok, what you told me works for this simple program:
class HelloWorld:
_reg_clsid_ = "{4E5807E3-C445-4A3C-A4BC-FD81697B661A}"
_reg_progid_ = "Python.TestServer"
_public_methods_ = ['Hello']
def __init__(self):
pass
def Hello(self, who):
return "Hello" + who
regsvr32.exe tells me that registering the dll has succeeded and I can call
the function Hello from a VB .Net application.
But when I try to register another compiled dll, a more complicated one,
then win32traceutil gives me the following error when I try to register the
DLL:
Traceback (most recent call last):
File "<string>", line 1, in ?
File "boot_com_servers.py", line 62, in DllRegisterServer
File "win32com\server\register.pyc", line 404, in RegisterCl
AttributeError: Runescape instance has no attribute '__name__'
The file I tried to compile/register uses the modules sys, Image,
Imagechops, pythoncom and urllib.urlopen and works perfectly in non-compiled
mode.
I also tried running the exe I get when i set create_exe in the
setup.pyscript to True; that gives me the following error:
Traceback (most recent call last):
File "boot_com_servers.py", line 44, in ?
ImportError: dynamic module does not define init function (initrunescape)
Do you know what I might have done wrong?
Floris
On 6/26/06, Mark Hammond <mhammond at skippinet.com.au> wrote:
>
> > Py2exe supports making com servers as dlls or as exes. After I
> > create a com server with py2exe, how do I get it registered?
>
> If it is a .exe, you just run it. If it is a DLL, you use regsvr32.exe to
> register it - ie, you register them just like any other COM EXE or DLL
> files.
>
> > If I need to register additional registry keys when the
> > com server is registered, how is that handled?
>
> py2exe and pywin32 have special support for "DllRegisterServer" and
> "DLLUnregisterServer" functions - just create functions of this name in
> your
> main module, and py2exe will find and use them (see boot_com_servers.py in
> the py2exe distro). Your "normal" .py implemented COM objects can
> leverage
> the same thing by using something like:
>
> def DllRegisterServer():
> ...
> def DllUnregisterServer():
> ...
> if __name__=='__main__':
> win32com.server.register.HandleCommandLine(...,
>
> finalize_register=DllRegisterSe
> rver,
>
> finalize_unregister=DllUnregist
> erServer)
>
> Mark
>
> _______________________________________________
> Python-win32 mailing list
> Python-win32 at python.org
> http://mail.python.org/mailman/listinfo/python-win32
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/python-win32/attachments/20060626/2286ac30/attachment.htm
More information about the Python-win32
mailing list