[Zope-dev] DCOracle Problem on HPUX

Mark Postal postalm@nosc.mil
Wed, 17 May 2000 15:50:41 -0700


I'm running HPUX 10.20 and Oracle 8.0.3.  My goal is to use ZOracleDA,
but first I must get DCOracle working.  DCOracle compiles OK and I
am able to connect to the database when executing from the command line.
My test script is attached for reference.

My problem occurs when running in the Zope environment, as ZOracleDA Product
or
an External Method, DCOracle hangs in the oci_8.Logon() method.  I have to
kill
the python process to recover from the error.

Yes, I have ORACLE_HOME and LD_LIBRARY_PATH set.

I wrote a new module, just to login to Oracle, using code that I am
more familiar with.  Again with the same result, it works OK on the
command line but not in Zope.  I have included that code also, because
it shows where the hangup is.  In my module it hangs in OCIServerAttach.

Here's where I need help.  In both cases, its actually hanging in an Oracle
function (OCILogon in oci_8.c and OCIServerAttach in my module).

What might cause this?

Why does it happen in the Zope environment and not in the command line
environment?

How do I get this working?

Thanks in advance,
Mark Postal
postalm@nosc.mil

===========================================================================
# DCOracle test script
from string import join, split

# If threads are enabled, then put Oracle in thread-safe mode:
try: import thread
except: thread=None

if thread is not None: oci_.opinit(oci_.OCI_EV_TSF)
del thread


if __name__ == '__main__':
        connection_string = "system/xxxxxx"

        if environ.has_key('ORACLE_HOME'):
                print "ORACLE_HOME: ", environ['ORACLE_HOME']
        else:
                print "ORACLE_HOME not defined"
        if environ.has_key('ORACLE_SID'):
                print "ORACLE_SID: ", environ['ORACLE_SID']
        else:
                print "ORACLE_HOME not defined"
        if environ.has_key('TWO_TASK'):
                print "TWO_TASK: ", environ['TWO_TASK']
        else:
                print "TWO_TASK not defined"

        if oci_:
                print "Got oci_"
        if oci_8:
                print "Got oci_8"
                up, s = (split(connection_string, '@')+[''])[:2]
                u,  p = (split(up, '/')+[''])[:2]
                print "Logon: %s %s %s" % (u,p,s)
                sc=oci_8.Logon(u,p,s)
                _d=sc.lda()

                print "Logging off"
                oci_.ologof(_d)
===============================================================

static PyObject *
Logon(PyObject *ignored, PyObject *args)
{
        char *u, *p, *d;
        int lu, lp, ld;

        if (!PyArg_ParseTuple(args, "s#s#s#", &u, &lu, &p, &lp, &d, &ld))
                return NULL;

        Py_BEGIN_ALLOW_THREADS
        OCIInitialize(OCI_DEFAULT, NULL, NULL, NULL, NULL);
        OCIEnvInit(&envp, OCI_DEFAULT, NULL, NULL);
        OCIHandleAlloc(envp, (dvoid**)&hp, OCI_HTYPE_SVCCTX, NULL, NULL);
        OCIHandleAlloc(envp, (dvoid**)&ep, OCI_HTYPE_ERROR, NULL, NULL);
        OCIHandleAlloc(envp, (dvoid**)&svrp, OCI_HTYPE_SERVER, NULL, NULL);
        OCIHandleAlloc(envp, (dvoid**)&sesp, OCI_HTYPE_SESSION, NULL, NULL);
        OCIAttrSet(sesp, OCI_HTYPE_SESSION, u, lu, OCI_ATTR_USERNAME, ep);
        OCIAttrSet(sesp, OCI_HTYPE_SESSION, p, lp, OCI_ATTR_PASSWORD, ep);

        /* fails here */
printf("Attempting to attach to server\n");
        OCIServerAttach(svrp, ep, (text *) 0, 0, OCI_DEFAULT);
printf("Attached to server\n");

        OCIAttrSet(hp, OCI_HTYPE_SVCCTX, svrp, 0, OCI_ATTR_SERVER, ep);
        OCISessionBegin(hp, ep, sesp, OCI_CRED_RDBMS, OCI_DEFAULT);
        OCIAttrSet(hp, OCI_HTYPE_SVCCTX, sesp, 0, OCI_ATTR_SESSION, ep);
        Py_END_ALLOW_THREADS

        return Py_None;
}