473,322 Members | 1,421 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

win32com and com Record types

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.
Jul 18 '05 #1
2 3385
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.

Jul 18 '05 #2
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

Jul 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Justin Stockton | last post by:
I recently upgraded from ActivePython 2.2.2 to ActivePython 2.3.2 and I'm running into an issue importing the win32com.client module. Before installing the new version, I made sure to properly...
3
by: RJ | last post by:
Hi, I've been going over the Quick Start to Client side COM and Python and many other sources, but cannot find an example that will get my com/ActiveX .ocx USB device driver imported. The Excel...
2
by: Sibylle Koczian | last post by:
Hello, I've installed Python 2.4 and the win32 extensions, using administrator rights, under Windows XP in "C:\Programme". As this is a directory without spaces I didn't expect any problems. But...
4
by: mirandacascade | last post by:
O/S : Win2K vsn of Python: 2.4 Hoping to find information that provide information about error messages being encountered. Pythonwin session: Traceback (most recent call last): File...
12
by: vithi | last post by:
Hi Any one tell me where I can get (or download) python modules win32com or win32com.client because I have to use "Dispatch" thanks
2
by: Ray | last post by:
Hi, I need to use cell's background color. when I record a macro from excel, it shows: Rows("7:7").Select With Selection.Interior .ColorIndex = 8 .Pattern = xlSolid
11
by: Bill Davy | last post by:
I am trying to edit Contacts in Outlook. This is so I can transfer numbers from my address book which is an Excel spreadsheet to my mobile phone. I came across the following snippet of code which...
4
by: sterling | last post by:
I'm curious as to why the difference between IDLE and pythonWin when using win32com. opening an excel file, i've attempted to grab the chart information out of the file. commands like co =...
0
by: Tim Golden | last post by:
Lave wrote: You have broadly two approaches here, both involving automating Word (ie using the COM object model it exposes, referred to in another post in this thread). 1) Use the COM model...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.