HELP! win32com, COM, Invoke problem

TB tblin at my-deja.com
Tue Jan 2 18:01:20 EST 2001


Mark, thanks for your quick reply.

I did notice that if you I take out the parens, this statement will
work, but when it bombs at the next statement:

bo = form.CreateBO("Clarify.CBO.Generic")
the error message is
>>> Clarify.CBO.App.1.__LazyMap__(CreateSession) added something
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 0x12bbf54 with obj at 0x25e0990>
>>> Unhandled exception while debugging...
Traceback (most recent call last):
  File "c:\python20\win32com\client\dynamic.py", line 377, in
__getattr__
    return new.instancemethod(self._builtMethods_[attr], self,
self.__class__)
KeyError: CreateBO
>>> Calling GetIDsOfNames for property CreateBO in Dispatch container
<unknown>
>>> Unhandled exception while debugging...
Traceback (most recent call last):
  File "c:\python20\win32com\client\dynamic.py", line 413, in
__getattr__
    ret = self._mapCachedItems_[retEntry.dispid]
KeyError: 4
>>> Attribute CreateBO not in cache
>>> Getting property Id 0x4 from OLE object
>>> Unhandled exception while debugging...
Traceback (most recent call last):
  File "c:\python20\win32com\client\dynamic.py", line 423, in
__getattr__
    ret = self._oleobj_.Invoke
(retEntry.dispid,0,pythoncom.DISPATCH_PROPERTYGET,1)
com_error: (-2147352567, 'Exception occurred.',
(0, 'Form.CreateBO', 'Invalid class string\015\012', None, 0, -
2146827287), None)
[Dbg]>>>

the exception is thrown at the same Invoke line in dynamic.py. This
time CreateBO requires one parameter, but when it's called with Invoke
(...DISPATCH_PROPERTYGET,1), it didn't thrown an exception of
BADCONTEXT, but it threw a 'Invalid class string', is it a bug in the
control I'm using?

As for Makepy, I tried before but it didn't help. Let me make it more
clearly. The Clarify.CBO.App.1 sits in a DLL called BOCLIENT.DLL, but
all other stuff, session, FormContext etc sits in another DLL called
AXCOMMON.OCX. After I ran makepy on both files, I saw 2 py files
created, but when I step through the program I found it only used the
1st py file, not the 2nd one, which contains FormContext and etc. I
don't know COM so I can't explain why. Could you explain a little bit?

I wonder how VB or JScript got this to work, and how can I mimic the
same behavior in Python. Also, I'd like to volunteer sometime to study
and contribute if neccessary.

Thanks again and happy new year.

--TB

In article <3A51EDBF.3000808 at ActiveState.com>,
  Mark Hammond <MarkH at ActiveState.com> wrote:
> TB wrote:
>
> >   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?
>
> It is quite common for some COM objects to allow certain methods to
be
> accessed as either a method or property.  This is mainly for VB,
where
> you can't (could not) use parens with a sub.
>
> So, that happens with
>
> sess.CreateFormContext()
>
> is that the "CreateFormContent" is making the method call when simply
> referenced as a property.  This causes Python to try and execute the
> _result_ of the function - probably calling the default method on the
> FormContext object.
>
> Note that the traceback above has:
>
>  > File "f:\python20\win32com\client\dynamic.py", line 150, in
__call__
>  > return self._get_good_object_(apply
>
> This is what leads me to believe you can simply drop the parens.
Note
> that if you run "makepy" over this TLB, it will work correctly.
>
> Mark.
>
> >
> > 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/
>
>

--
--TB


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



More information about the Python-list mailing list