| 1239 | } |
| 1240 | |
| 1241 | static PyObject * |
| 1242 | cursor_create(UpsCursor *self, PyObject *args) |
| 1243 | { |
| 1244 | UpsDatabase *db = 0; |
| 1245 | UpsTransaction *txn = 0; |
| 1246 | |
| 1247 | if (!PyArg_ParseTuple(args, "O!|O:create", &UpsDatabase_Type, &db, &txn)) |
| 1248 | return (0); |
| 1249 | |
| 1250 | if (self->cursor) |
| 1251 | ups_cursor_close(self->cursor); |
| 1252 | |
| 1253 | /* check if first object is either a Transaction or None */ |
| 1254 | if (txn && txn == (UpsTransaction *)Py_None) |
| 1255 | txn = 0; |
| 1256 | |
| 1257 | ups_status_t st = ups_cursor_create(&self->cursor, db->db, |
| 1258 | txn ? txn->txn : 0, 0); |
| 1259 | if (st) |
| 1260 | THROW(st); |
| 1261 | |
| 1262 | self->db = db; |
| 1263 | |
| 1264 | /* add the new cursor to the database */ |
| 1265 | if (!db->cursorlist) { |
| 1266 | db->cursorlist = PyList_New(10); |
| 1267 | if (!db->cursorlist) |
| 1268 | return (0); |
| 1269 | } |
| 1270 | if (PyList_Append(db->cursorlist, (PyObject *)self)) |
| 1271 | return (0); |
| 1272 | Py_INCREF(self); |
| 1273 | |
| 1274 | return ((PyObject *)self); |
| 1275 | } |
| 1276 | |
| 1277 | static PyObject * |
| 1278 | cursor_clone(UpsCursor *self, PyObject *args) |
no test coverage detected