win32com and com Record types

Discussion in 'Python' started by Mike Margerum, Aug 19, 2003.

  1. Hi I am trying to using a COM server I built in C++. I ran GenPy on
    my type library and I am able to instantiate objects from the server.
    What I can't figure out is how to create/use Record types from my COM
    server. I see them defined in my generated py file as a map

    RecordMap = {
    'FormRecord': '{F6EBBC2A-E2D5-4921-A498-EA80AE851012}',
    'ICD9Record': '{FA83723F-55F6-4D17-8309-A9D323A4FD01}',
    'BrandRecord': '{AD4B5647-E78A-447B-A041-EEC59E89D3F6}',
    }

    How Do i instantiate one so I can use it in one of my methods that
    takes a BrandRecord by reference?

    This is a snippet of VB code that works

    Dim db As New BrandDb
    db.Open ("c:\temp\irx2_brand.pdb")
    Dim brandRec As BrandRecord
    While i < db.RecordCount
    db.GetBrand i, brandRec, 1 'use 0 instead of 1 to not load
    form data
    List1.AddItem brandRec.MasterIndex & " " & brandRec.Id & " " &
    brandRec.Description

    This is my python code that is working minus the GetBrand call

    from win32com.client import *
    from PDBUtils import *
    db = BrandDb()
    print db.Version
    db.Open(r"c:\temp\irx2_brand.pdb")
    for i in range(0,db.RecordCount):
    print i

    Thanks a lot for the help.
    Mike Margerum, Aug 19, 2003
    #1
    1. Advertising

  2. Mike Margerum

    Mark Hammond Guest

    Mike Margerum wrote:
    > Hi I am trying to using a COM server I built in C++. I ran GenPy on
    > my type library and I am able to instantiate objects from the server.
    > What I can't figure out is how to create/use Record types from my COM
    > server. I see them defined in my generated py file as a map
    >
    > RecordMap = {
    > 'FormRecord': '{F6EBBC2A-E2D5-4921-A498-EA80AE851012}',
    > 'ICD9Record': '{FA83723F-55F6-4D17-8309-A9D323A4FD01}',
    > 'BrandRecord': '{AD4B5647-E78A-447B-A041-EEC59E89D3F6}',
    > }
    >
    > How Do i instantiate one so I can use it in one of my methods that
    > takes a BrandRecord by reference?
    >
    > This is a snippet of VB code that works
    >
    > Dim db As New BrandDb
    > db.Open ("c:\temp\irx2_brand.pdb")
    > Dim brandRec As BrandRecord
    > While i < db.RecordCount
    > db.GetBrand i, brandRec, 1 'use 0 instead of 1 to not load
    > form data
    > List1.AddItem brandRec.MasterIndex & " " & brandRec.Id & " " &
    > brandRec.Description


    You can create a record object by using:

    r = win32com.client.Record("RecordName", object)

    where "RecordName" is the name of the record, and 'object' is &any* COM
    object defined in the same type library.

    See win32com\test\testvb for some real examples.

    Mark.
    Mark Hammond, Aug 19, 2003
    #2
    1. Advertising

  3. Mike Margerum

    Chuck Spears Guest

    When I run this code, it fails on the line where i try to create a
    record. Thanks again for the help.

    import win32com.client
    db=win32com.client.Dispatch("PDBUtils.BrandDb")
    db.Open (r"c:\temp\irx2_brand.pdb")
    for i in range(0,db.RecordCount):
    print i
    rec = win32com.client.Record("BrandRecord", db)


    0
    Traceback (most recent call last):
    File "c:\temp\test\comTest.py", line 18, in ?
    rec = win32com.client.Record("BrandRecord", db)
    File "C:\PYTHON22\lib\site-packages\win32com\client\__init__.py",
    line 392, in Record
    object = gencache.EnsureDispatch(object)
    File "C:\PYTHON22\lib\site-packages\win32com\client\gencache.py",
    line 442, in EnsureDispatch
    raise TypeError, "This COM object can not automate the makepy
    process - please run makepy manually for this object"
    TypeError: This COM object can not automate the makepy process -
    please run makepy manually for this object
    Chuck Spears, Aug 20, 2003
    #3
    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. =?Utf-8?B?SnVzdGlu?=

    Retrieving Record Key while creating the record.

    =?Utf-8?B?SnVzdGlu?=, Oct 4, 2004, in forum: ASP .Net
    Replies:
    4
    Views:
    614
    =?Utf-8?B?SnVzdGlu?=
    Oct 5, 2004
  2. André
    Replies:
    0
    Views:
    3,727
    André
    Jun 25, 2006
  3. MRW
    Replies:
    0
    Views:
    364
  4. THurkmans
    Replies:
    2
    Views:
    587
  5. Frits van Soldt

    How to insert a new record in detailsview when there are no record

    Frits van Soldt, Nov 16, 2005, in forum: ASP .Net Web Controls
    Replies:
    2
    Views:
    717
    Frits van Soldt
    Nov 17, 2005
Loading...

Share This Page