[Zope-Checkins] CVS: Products/DCOracle2/src - dco2.c:1.130
Matthew T. Kromer
matt@zope.com
Thu, 13 Feb 2003 19:01:51 -0500
Update of /cvs-repository/Products/DCOracle2/src
In directory cvs.zope.org:/tmp/cvs-serv21635/src
Modified Files:
dco2.c
Log Message:
DB API 2.0 test suite compatibility fixes
=== Products/DCOracle2/src/dco2.c 1.129 => 1.130 ===
--- Products/DCOracle2/src/dco2.c:1.129 Sat Dec 21 15:27:36 2002
+++ Products/DCOracle2/src/dco2.c Thu Feb 13 19:01:20 2003
@@ -578,6 +578,7 @@
static PyObject *Connect(PyObject *self, PyObject *args);
static void ServerContext_dealloc(ServerContext *self);
static PyObject *ServerContext_getattr(ServerContext *self, char *name);
+static PyObject *ServerContext_close(ServerContext *self, PyObject *args);
static PyObject *ServerContext_cursor(ServerContext *self, PyObject *args);
static PyObject *ServerContext_commit(ServerContext *self, PyObject *args);
static PyObject *ServerContext_prepare(ServerContext *self, PyObject *args);
@@ -1057,6 +1058,9 @@
{"cursor", (PyCFunction) ServerContext_cursor, METH_VARARGS,
"allocate a cursor"
},
+ {"close", (PyCFunction) ServerContext_close, METH_VARARGS,
+ "close a connection"
+ },
{"commit", (PyCFunction) ServerContext_commit, METH_VARARGS,
"commit a transaction"
},
@@ -1755,19 +1759,18 @@
}
/*
-** ServerContext_dealloc
+** ServerContext_close
**
-** Called when a server context goes out of scope; hang up the connection
-** to the database!
+** Called to hang up the connection to the database
*/
-static void ServerContext_dealloc(ServerContext *self) {
+static PyObject *ServerContext_close(ServerContext *self,PyObject *args) {
sword status;
ub4 errcode;
char errbuf[OCI_ERROR_MAXMSG_SIZE];
- TRACE(T_ENTRY, ("sA", "ServerContext_dealloc", self));
+ TRACE(T_ENTRY, ("sA", "ServerContext_close", self));
Py_XDECREF(self->tctx);
self->tctx = NULL;
@@ -1788,6 +1791,7 @@
fprintf(stderr, "OCI_ERROR at %s:%d: %s", __FILE__,
__LINE__ - 8, errbuf);
}
+
}
/* Disconnect from the server */
@@ -1806,8 +1810,34 @@
fprintf(stderr, "OCI_ERROR at %s:%d: %s", __FILE__,
__LINE__ - 8, errbuf);
}
+
}
+
+ TRACE(T_EXIT, ("s", "ServerContext_close"));
+
+ Py_INCREF(Py_None);
+
+ return Py_None;
+}
+
+/*
+** ServerContext_dealloc
+**
+** Called when a server context goes out of scope; hang up the connection
+** to the database!
+*/
+
+static void ServerContext_dealloc(ServerContext *self) {
+
+ PyObject *obj;
+ sword status;
+
+ TRACE(T_ENTRY, ("sA", "ServerContext_dealloc", self));
+
+ obj = ServerContext_close(self, Py_None);
+ Py_XDECREF(obj);
+
/* Deallocate the session handle */
if (self->usrhp) {
@@ -3800,6 +3830,13 @@
ub4 width;
TRACE(T_ENTRY,("sAd", "Cursor_ResultSet", self, count));
+
+ if (self->definition == NULL) {
+ TRACE(T_ERROR,("ss","Cursor_ResultSet","description is NULL"));
+ PyErr_SetString(ProgrammingErrorObject,
+ "cursor description is None");
+ return NULL;
+ }
self->batchsz = count;