Need Help building COM server in python
John Urberg
jurberg at my-deja.com
Thu Jun 14 11:55:38 EDT 2001
michiel at htcs.nl (michiel) wrote:
> 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)
>
> if __name__=='__main__':
> import win32com.server.register
> print "Registering COM server..."
> win32com.server.register.UseCommandLine(HelloWorld)
[...]
> PROBLEM:
>
> Registration of the object works.
> Creation of the object works (x=createobject("python.object")),
> but then there are no methodes I can access: "there is no such method"
>
> Can someone help me out or send me an example of a useable COM server
> object written in python?
Try using: x = CreateObject("Python.TestServer"). The value you put
in_reg_progid_ is what clients should use to create the object.
Regards,
John Urberg
More information about the Python-list
mailing list