makepy support for versioning

Discussion in 'Python' started by Jim Kerr, Jun 7, 2004.

  1. Jim Kerr

    Jim Kerr Guest

    Does makepy always respect versioning of interfaces? It appears as
    though makepy correctly handles versioning of objects you obtain
    directly, but not for objects you get via a function call.

    Here's a simple example to illustrate the point. I created the
    C++-based server for this example by pilfering some code in Andrew
    Troelsen's book on COM and ATL.

    car = Dispatch("ScriptibleCoCar.DualCoCar")
    person = Dispatch("ScriptibleCoCar.Person") # a Person object
    carOwner = car.Person # also a Person
    object

    Both the Car and the Person classes have two versions, and makepy
    handles this correctly:

    >>> car

    <win32com.gen_py.ScriptibleCoCar 1.0 Type Library.IDualCoCar2
    instance at 0x17800328>
    >>> person

    <win32com.gen_py.ScriptibleCoCar 1.0 Type Library.IPerson2
    instance at 0x17800368>

    (Notice the suffix 2 in both cases). OTOH, the Person object obtained
    via car.Person is a version 1 thingie:

    >>> carOwner

    <win32com.gen_py.ScriptibleCoCar 1.0 Type Library.IPerson
    instance at 0x14968112>

    If I try to use QueryInterface to get a reference to a version 2
    object, it fails:

    >>> IID_IPerson2 = "{38332D31-6631-48E9-B62E-449864003395}"
    >>> carOwner._oleobj_.QueryInterface(IID_IPerson2)

    Traceback (most recent call last):
    File "<interactive input>", line 1, in ?
    TypeError: There is no interface object registered that supports
    this IID

    Late binding works fine, however:

    >>> import win32com.client.dynamic
    >>> dcar = win32com.client.dynamic.Dispatch("ScriptibleCoCar.DualCoCar")
    >>> dperson = dcar.Person
    >>> dperson.Name, dperson.ID, dperson.Address # Address is new

    in version 2
    (u'Phony', 123, u'00 Anywhere Place')

    I'm kinda stuck here. I could live with using late binding, but the
    interface I need to use has a lot of properties with parameters, and
    makepy seems like the easiest way to deal with those. So my questions
    are:
    1) Is there a way around this issue with makepy?
    2) If not, is there a way to set the values of properties with
    parameters using late binding?

    Thanks for the help!

    Jim
     
    Jim Kerr, Jun 7, 2004
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. bk
    Replies:
    0
    Views:
    392
  2. bk
    Replies:
    0
    Views:
    372
  3. Alv Mart

    ADO and Makepy

    Alv Mart, Nov 12, 2003, in forum: Python
    Replies:
    1
    Views:
    359
    Mark Hammond
    Nov 12, 2003
  4. Gerson Kurz
    Replies:
    3
    Views:
    349
    Trent Mick
    Nov 24, 2003
  5. Stefano Masini
    Replies:
    2
    Views:
    1,288
    Markus Wankus
    Mar 6, 2004
Loading...

Share This Page