Newbie Q: Win32, COM, Dispatch, Oracle OLE

Mark Hammond mhammond at skippinet.com.au
Mon May 1 20:08:52 EDT 2000


"Torgo Jr" <torgojr at my-deja.com> wrote in message
news:8ek444$5br$1 at nnrp1.deja.com...
> I'm confused on how to implement Oracles Objects For OLE in Python.
> I browsed this newsgroup and came up with using "makepy.py -i"
> to set the module correctly.  What I want to do is create a
> OraSession object, set some parameters, and call a method in OraSession
> that returns an OraDatabase object, but I am not sure what I am doing
> wrong:
>
> >>> from win32com.client import gencache
> >>> mod = gencache.EnsureModule('{F2D4ED20-FFD3-101A-ADF2-
> 04021C007002}', 0, 3, 0)
> >>> # previous works fine, can see __dict__.keys() entries

> >>> oraS = mod.OraSession()  # fails

The first thing to try is to avoid using the module directly.  If Oracle
is behaving, you should be able to do the gencache line, then a simple
"win32com.client.Dispatch("Oracle.Whatever")

You probably saw a recent thread where the object didnt behave itself, so
we did need to go directly to the makepy module.

If this is also true for you, you should probably have a look at the .py
file generated by Python.

You will see a couple of categories of classes.  The first set look like
[from DAO]:

class _User(DispatchBaseClass):
 CLSID = pythoncom.MakeIID('{00000069-0000-0010-8000-00AA006D2EA4}')
 ... lots of methods removed ...

The other looks like:

# This CoClass is known by the name 'DAO.User.36'
class User(CoClassBaseClass): # A CoClass
 CLSID = pythoncom.MakeIID("{00000107-0000-0010-8000-00AA006D2EA4}")
 coclass_sources = [
 ]
 coclass_interfaces = [
  _User,
 ]
 default_interface = _User

If you need to use a class explicitly, it probably need to be the first
type rather than the second - eg, you would use "_User" instead of "User"

Mark.






More information about the Python-list mailing list