HELP! win32com, COM, Invoke problem

TB tb_lin at hotmail.com
Tue Jan 2 02:14:03 EST 2001


Hi,

I'm new to Python and COM, so forgive me if I'm using the wrong terms
or etc. I really want to replace M$ VBScript or JScript with Python.
Please help.

In a nutshell, the problem is I'm having problem converting a Jscript
to a Python, the working JScript looks like

==start JScript==
ClfyApp = WScript.CreateObject("Clarify.CBO.App.1");
ClfySession = ClfyApp.CreateSession();
ClfySession.Login("sa", "sa");
ClfyForm = ClfySession.CreateFormContext();
.....
== end JScript

==Start Python==
import win32com.client

win32com.client.dynamic.debugging = 1
win32com.client.dynamic.debugging_attr = 1

app = win32com.client.Dispatch("Clarify.CBO.App.1")
sess = app.CreateSession()
print sess.SessionId
print sess.GetCurrencyNameList

sess.Login("sa","sa")
# all works until here
form = sess.CreateFormContext() # something wrong here...

=== end Python ===

The error message looks like:
Attribute SessionId not in cache
Getting property Id 0x1 from OLE object
OLE returned  UNO_11FFD521
UNO_11FFD521
Calling GetIDsOfNames for property GetCurrencyNameList in Dispatch
container CreateSession
Attribute GetCurrencyNameList not in cache
Getting property Id 0x10 from OLE object
OLE returned  USD - US Dollar (Base Currency)
USD - US Dollar (Base Currency)
Calling GetIDsOfNames for property Login in Dispatch container
CreateSession
Attribute Login not in cache
Getting property Id 0x3 from OLE object
Calling GetIDsOfNames for property CreateFormContext in Dispatch
container CreateSession
Attribute CreateFormContext not in cache
Getting property Id 0x5 from OLE object
OLE returned  <PyIDispatch at 0x1201194 with obj at 0x2349e20>
Traceback (most recent call last):
  File "f:\python20\pythonwin\pywin\framework\scriptutils.py", line
301, in RunScript
    exec codeObject in __main__.__dict__
  File "F:\tb\cbo\test1.py", line 13, in ?
    form = sess.CreateFormContext()
  File "f:\python20\win32com\client\dynamic.py", line 150, in __call__
    return self._get_good_object_(apply
(self._oleobj_.Invoke,allArgs),self._olerepr_.defaultDispatchName,None)
com_error: (-2147352573, 'Member not found.', None, None)

I used to debugger to dig into the dynamic.py, at line #422
try:
 ret =
self._oleobj_.InvokeretEntry.dispid,0,pythoncom.DISPATCH_PROPERTYGET,1)
 except pythoncom.com_error, details:
....

it doesn't throw an exception even CreateFormContext is a method, and
the invoked is called with DISPATCH_PROPERTYGET. Is it supposed to
throw an exception when a method is called with PROPERTYGET?

what OLEVIEW says about Session
[
  uuid(E8000132-8693-11D0-B8B1-080009B6AB17)
]
dispinterface Session {
    properties:
        [id(0xfffffffc)
]
        IUnknown* _NewEnum;
        [id(0x00000001), helpstring("SessionID")
]
        BSTR SessionId;
        [id(0x00000002), helpstring("Set this property to True when
using JScript")
]
        VARIANT_BOOL JScript;
    methods:
        [id(0x00000003), helpstring("Log into Clarify system")]
        void Login(
                        BSTR pLoginName,
                        BSTR pPassword,
                        [optional] VARIANT LoginType,
                        [optional] VARIANT AssocDefault);
        [id(0x00000004), helpstring("Log out")]
        void Logout();
        [id(0x00000005), helpstring("Creates a Clarify Form Context
object")]
        FormContext* CreateFormContext();
        [id(0x00000006), helpstring("Builds a session cookie string")]
......


--TB


Sent via Deja.com
http://www.deja.com/



More information about the Python-list mailing list