[python-win32] Registering a Server COM to make it visible in thereference list

Rasjid Wilcox rasjidw at gmail.com
Wed Aug 1 15:53:31 CEST 2007


On 7/30/07, Mark Hammond <mhammond at skippinet.com.au> wrote:
> There should be no need to create an IDL file - enough interfaces are
> exposed so that we can create the typelib directly.

Ah, after some looking around, I see that there is
pythoncom.CreateTypeLib and CreateTypeLib2.  Is this what you mean?

> The problem I see is how to infer the intent of the Python programmer, who
> probably does *not* want to author the interfaces externally.  In other
> words, the typelib should be able to be created only from information inside
> the .py file.
>
> class MyCOMObject:
>    ...
>    def Foo(self, bar):
>      return "foo"
>
> Somehow we need to allow this to be annotated so that the programmer can say
> "bar must be a string, and the result must be a string".
>
> Last I thought about this, Python 'decorators' were just a gleam in
> someone's eye, so they may offer a solution.  Ideally, we would look at
> tools like pyrex which may already have grown ways to annotate types of
> things it deals with.

I was assuming the use of decorators, but it also may be possible to
just extend the current class variable syntax.

> Another (easier) issue is to decide on the semantics for creation of the
> typelib - eg, do we force the programmer to nominate the typelib GUID, and
> any version annotations necessary?  How hard do we try to stop them shooting
> themselves in the foot by, for example, changing method signatures without
> chaning the version or GUID? etc.

The other idea I had was to use something like zope.interface where
one defines the interfaces in a separate class.  This sits half way
between using something like IDL where the interfaces are in a
separate file (and different language) and using decorators / class
variables where your class has all the information.  The advantage
that I can see is that it makes it clearer to the programmer when they
need to change the version number / GUID of the typelib.  If they
change the interface class, they need to change the version number.
If they just change the implementation class, they do not.  It may
also make it easier to write unit tests to check that the
implementation class complies with the interface.

Thoughts?

Cheers,

Rasjid.


More information about the python-win32 mailing list