win32com and com Record types

Mike Margerum margerum at yahoo.com
Tue Aug 19 12:12:50 EDT 2003


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.




More information about the Python-list mailing list