[python-win32] Converting VB COM register program to Python
Tim Roberts
timr at probo.com
Wed Oct 3 18:53:20 CEST 2007
r c wrote:
>
> I'm trying to convert VB code that registers COM+ components to
> Python. I'm unable to set values on COMAdminCatalogObject using the
> Value() method, it seems to think I'm trying to call the get method?
>
> ...
>
> 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)
In this case, where an indexed property had both a "Get" and a "Let"
handler, the Python COM stuff generates a "Value" function for the "Get"
part, and a "SetValue" function for the "Let" part.
So, you want:
objCOMAdminCatalogObject.SetValue("ID", AppID)
--
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.
More information about the python-win32
mailing list