Newbie Q: Win32, COM, Dispatch, Oracle OLE

Torgo Jr torgojr at my-deja.com
Tue May 2 10:02:43 EDT 2000


In article <o0pP4.9101$v85.58393 at news-server.bigpond.net.au>,
  "Mark Hammond" <mhammond at skippinet.com.au> wrote:
> "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.

Thanks for replying.  Perhaps I'm not understanding things
correctly (keep in mind I just have a general understanding
of COM).  The Oracle objects work like so:  You establish
a Session object, which establishes which actual database
you are talking to (usually a TCP port number), and this
Session object can pool multiple database connections, which
kind of act like a user logged into Oracle.  What I can
get to work is the Session, except I can't get it to return
a database object.

>>> from win32com.client import Dispatch
>>> oraS = Dispatch("OracleInProcServer.XOraSession")
>>> oraS.CreateDatabasePool(1,3,3600,"DEV","USER/PASS",0) # Create pool
of db connections
>>> oraS.Name    # test print database "name"
'3'
>>> oraS.OIPVersionNumber   # test print version number
'8.0.5.3.4'
>>> # Looks like the session object was created correctly, along with
>>> # the database connection pool.  Now try and return a database
>>> # connection object from the session object.
>>> oraDB = oraS.GetDatabaseFromPool(10)
Traceback (innermost last):
  File "<interactive input>", line 1, in ?
  File "<COMObject OracleInProcServer.XOraSession>", line 2, in
GetDatabaseFromPool
com_error: (-2147352573, 'Member not found.', None, None)
>>> # Strange, it looks like this method should work:
>>> oraS.__dict__["_builtMethods_"]
{'CreateDatabasePool': <function CreateDatabasePool at
549c70>, 'GetDatabaseFromPool': <function GetDatabaseFromPool at
54dfa0>}
>>> # Why doesn't it see the GetDatabaseFromPool call????


Thanks for the assistance.

--
"Did I mention I'm immense and immortal?"
Joel Robinson


Sent via Deja.com http://www.deja.com/
Before you buy.



More information about the Python-list mailing list