Thank you for that, Mark.

I am afraid it still doesn't work

------------------------------------------
>>> from win32com.client import gencache
>>> ea=gencache.EnsureModule('{64FB2BF4-9EFA-11D2-8307-C45586000000}', 0, 2,
10)
>>> import win32com.client
>>> rep = win32com.client.Dispatch('EA.Repository')
>>> rep = ea.IRepository(rep)
>>> rep.OpenFile2("C:\Test.eap","","")
Traceback (most recent call last):
  File "<interactive input>", line 1, in ?
  File
"C:\Python24\lib\site-packages\win32com\gen_py\64FB2BF4-9EFA-11D2-8307-C4558
6000000x0x2x10.py", line 4480, in OpenFile2
    , Username, Password)
com_error: (-2147352573, 'Member not found.', None, None)
------------------------------------------------

Alex


> -----Original Message-----
> From: Mark Hammond [mailto:[EMAIL PROTECTED]
> Sent: Thursday, October 13, 2005 2:01 PM
> To: Alex Jouravlev; python-win32@python.org
> Subject: RE: [python-win32] Possible bug: what information to provide
>
>
> > > > One more strange thing:
> > > > MakePy recognised the object as "IRepository" rather then
> "Repository"
> > >
> > > I'm not sure what you mean here.  Please post a complete code sample,
> > > including all output that confuses you or you believe to be wrong.
> > >
> > Makepy.py output (fragment, for information about the Object)
> > -----------------------------------------------
> > class IRepository(DispatchBaseClass):
>
> Right - that is normal.  It is indeed the interface that has the method -
> the "coclass" described in the file probably has a reference to that
> interface - a coclass may implement many interfaces.
>
> > > The code above is not using makepy, even though it may have
> > > been run.  You
> > > could try creating the object using
> > > win32com.client.gencache.EnsureDispatch
> >
> > I tried, here is the result:
> > -----------------------------------
> > >>> rep = win32com.client.gencache.EnsureDispatch('EA.Repository')
> > Traceback (most recent call last):
> >   File "<interactive input>", line 1, in ?
> >   File "C:\Python24\Lib\site-packages\win32com\client\gencache.py", line
> > 543, 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
>
> Sadly, this object is not providing its typeinfo at runtime.  If
> you can get
> in touch with the developers, ask them to consider adding this IDispatch
> typeinfo support - they already have the typeinfo available from their
> typelib, so it should be quite easy to do.
>
> In the meantime, you need to explicitly "cast" your objects into these
> makepy objects.  You should start by running "makepy.py -i" (from a
> command-prompt).  Here is what I get when I pick some random lib:
>
>  IAS Helper COM Component 1.0 Type Library
>  {6BC096BB-0CE6-11D1-BAAE-00C04FC2E20D}, lcid=0, major=1, minor=0
>  >>> # Use these commands in Python code to auto generate .py support
>  >>> from win32com.client import gencache
>  >>> gencache.EnsureModule('{6BC096BB-0CE6-11D1-BAAE-00C04FC2E20D}', 0, 1,
> 0)
>
> You should add these lines to your code - but with one change:
>
> > from win32com.client import gencache
> > mod = gencache.EnsureModule('{6BC096BB-0CE6-11D1-BAAE-00C04FC2E20D}', 0,
> 1, 0)
>
> Note the last line - 'mod ='.  This will be the makepy module, as imported
> from the gen_py directory.  You can then write:
>
> rep = win32com.client.Dispatch('EA.Repository')
> # Now 'cast' it to an IRepository object.
> rep = mod.IRepository(rep)
>
> print repr(rep) # Should now print a repr that indicates it is a makepy
> object.
>
> You will need to this whenever you get a "new" object.  Eg, let's
> say there
> was a "GetApplication()" method on a repository.
>
> app = rep.GetApplication()
> print repr(app) # will probably say "<COM object ...>" - not what
> you want.
> app = mod.IApplication(app) # Cast to a mythical IApplication object.
> print repr(app) # should show the makepy object.
>
> Hope that makes sense,
>
> Mark
>
>


_______________________________________________
Python-win32 mailing list
Python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32

Reply via email to