Need Help building COM server in python

Michael Hudson mwh at python.net
Thu Jun 14 06:12:07 EDT 2001


michiel at htcs.nl (michiel) writes:

> Hi,
> 
> First of all, I'm a newbie, so my question may be simple.
> 
> I have tried to make a simple COM object in python for the use in VB
> or Visual FoxPro. Therefore I have used the tutorial for building a
> COM server object in python.
> 
> CODE CLASS:
> 
> class HelloWorld:
>     _reg_clsid_  = "{D4FF29AD-BCDE-4FE2-9896-892D2EBB5180}"
>     _reg_desc_   = "Python Test COM Server"
>     _reg_progid_ = "Python.TestServer"
> 
>     _public_methods_ = ['Hello']
>     _public_attrs_ = ['softspace', 'noCalls']
>     _readonly_attrs_ = ['noCalls']
>     
> def __init__(self):
>     self.softspace = 1
>     self.noCalls = 0
> def Hello(self, who):
>     self.noCalls = self.noCalls + 1
>     return "Hello" + " " * self.softspace + str(who)

These methods need to be indented into the class body.  I've no idea
if that's your only problem...

> 
> if __name__=='__main__':
>     import win32com.server.register 
>     print "Registering COM server..."
>     win32com.server.register.UseCommandLine(HelloWorld)

Cheers,
M.

-- 
  That one is easily explained away as massively intricate
  conspiracy, though.            -- Chris Klein, alt.sysadmin.recovery



More information about the Python-list mailing list