Need Help building COM server in python
Alex Martelli
aleaxit at yahoo.com
Thu Jun 14 07:56:43 EDT 2001
"michiel" <michiel at htcs.nl> wrote in message
news:844df35f.0106140116.5f706fcf at posting.google.com...
...
> 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)
This looks misaligned to me (if you're using tabs, it could
be the tabs-eating behavior many MS newsreaders show -- one
more reason to *ONLY USE SPACES*!-). Make sure the def
keywords are aligned with the rest of HelloWorld's classbody,
and the methods' bodies indented further.
> PROBLEM:
>
> Registration of the object works.
> Creation of the object works (x=createobject("python.object")),
This cannot be creating the object you just described! Its ProgID:
> _reg_progid_ = "Python.TestServer"
is as you see Python.TestServer, ***NOT*** python.object. So
you may be creating something completely different.
> Can someone help me out or send me an example of a useable COM server
> object written in python?
Your works just fine, once the def's & bodies thereof are
indented 4 spaces rightwards, and when instantiated with
the actual ProgID it's registering with.
Alex
More information about the Python-list
mailing list