win32com COMAdminCatalogObject Value method

R

rc

I'm trying to convert VB code that registers COM+ components to
Python. However, I'm unable to set values on COMAdminCatalogObject
using the Value() method, it seems to think I'm trying to call the get
method.

VB Code:
Dim cat As COMAdminCatalog
Set cat = New COMAdminCatalog
Dim apps As COMAdminCatalogCollection
Set apps = cat.GetCollection("Applications")
Dim app As COMAdminCatalogObject
Set app = apps.Add
app.Value("ID") = AppID


Python Code:
objCOMAdminCatalog =
win32com.client.Dispatch("COMAdmin.COMAdminCatalog")
objApplications = objCOMAdminCatalog.GetCollection("Applications")
objCOMAdminCatalogObject = objApplications.Add()
print "ID", objCOMAdminCatalogObject.Value("ID") #This is returning
the random ID
# app.Value("ID") = AppID # SyntaxError: can't assign to function call
objCOMAdminCatalogObject.Value("ID", AppID) #Exception thrown

Returns the following error:
TypeError: Value() takes at most 2 arguments (3 given)
 
R

Roger Upole

rc said:
I'm trying to convert VB code that registers COM+ components to
Python. However, I'm unable to set values on COMAdminCatalogObject
using the Value() method, it seems to think I'm trying to call the get
method.

VB Code:
Dim cat As COMAdminCatalog
Set cat = New COMAdminCatalog
Dim apps As COMAdminCatalogCollection
Set apps = cat.GetCollection("Applications")
Dim app As COMAdminCatalogObject
Set app = apps.Add
app.Value("ID") = AppID


Python Code:
objCOMAdminCatalog =
win32com.client.Dispatch("COMAdmin.COMAdminCatalog")
objApplications = objCOMAdminCatalog.GetCollection("Applications")
objCOMAdminCatalogObject = objApplications.Add()
print "ID", objCOMAdminCatalogObject.Value("ID") #This is returning
the random ID
# app.Value("ID") = AppID # SyntaxError: can't assign to function call
objCOMAdminCatalogObject.Value("ID", AppID) #Exception thrown

Returns the following error:
TypeError: Value() takes at most 2 arguments (3 given)

Try objCOMAdminCatalogObject.SetValue("ID", AppID).

Roger
 
R

rc

Try objCOMAdminCatalogObject.SetValue("ID", AppID).
Roger- Hide quoted text -

- Show quoted text -

When I try that I get exception:
AttributeError: Add.SetValue

I think the only valid methods are: Key(), Name(), Valid() and Value()

The thing I'm most confused about is that it seems to be getting into
the __getattr__ method, not the set, here's the whole error:
Traceback (most recent call last):
File "C:\programming\python\dev\src\FullInstallScripts
\COMObjectFullInstall.py", line 74, in <module>
CreateApplication()
File "C:\programming\python\dev\src\FullInstallScripts
\COMObjectFullInstall.py", line 21, in CreateApplication
objCOMAdminCatalogObject.SetValue("ID", AppID)
File "C:\Python25\Lib\site-packages\win32com\client\dynamic.py",
line 496, in __getattr__
raise AttributeError, "%s.%s" % (self._username_, attr)
AttributeError: Add.SetValue
 
R

rc

I think you would get more help asking in (e-mail address removed)

Thank you, python-win32 was able to help.
makepy needed to be run on the COM object allowing SetValue to be
called:
win32com.client.gencache.EnsureModule(pywintypes.IID('{F618C513-
DFB8-11D1-A2CF-00805FC79235}'), 0x0, 1, 0)
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,818
Latest member
Brigette36

Latest Threads

Top