static PyObject * psyco_conn_set_session(connectionObject *self, PyObject *args, PyObject *kwargs) { PyObject *isolevel = Py_None; PyObject *readonly = Py_None; PyObject *deferrable = Py_None; PyObject *autocommit = Py_None; const char *c_isolevel = NULL; const char *c_readonly = NULL; const char *c_deferrable = NULL; int c_autocommit = self->autocommit; static char *kwlist[] = {"isolation_level", "readonly", "deferrable", "autocommit", NULL}; EXC_IF_CONN_CLOSED(self); EXC_IF_CONN_ASYNC(self, set_session); EXC_IF_IN_TRANSACTION(self, set_session); if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|OOOO", kwlist, &isolevel, &readonly, &deferrable, &autocommit)) { return NULL; } if (Py_None != isolevel) { if (!(c_isolevel = _psyco_conn_parse_isolevel(self, isolevel))) { return NULL; } } if (Py_None != readonly) { if (!(c_readonly = _psyco_conn_parse_onoff(readonly))) { return NULL; } } if (Py_None != deferrable) { if (self->server_version < 90100) { PyErr_SetString(ProgrammingError, "the 'deferrable' setting is only available" " from PostgreSQL 9.1"); return NULL; } if (!(c_deferrable = _psyco_conn_parse_onoff(deferrable))) { return NULL; } } if (Py_None != autocommit) { c_autocommit = PyObject_IsTrue(autocommit); if (-1 == c_autocommit) { return NULL; } } if (0 > conn_set_session(self, c_isolevel, c_readonly, c_deferrable, c_autocommit)) { return NULL; } Py_INCREF(Py_None); return Py_None; }
static PyObject * psyco_conn_set_isolation_level(connectionObject *self, PyObject *args) { int level = 1; PyObject *pyval = NULL; EXC_IF_CONN_CLOSED(self); EXC_IF_CONN_ASYNC(self, "isolation_level"); EXC_IF_TPC_PREPARED(self, "isolation_level"); if (!PyArg_ParseTuple(args, "O", &pyval)) return NULL; if (pyval == Py_None) { level = ISOLATION_LEVEL_DEFAULT; } /* parse from one of the level constants */ else if (PyInt_Check(pyval)) { level = PyInt_AsLong(pyval); if (level < 0 || level > 4) { PyErr_SetString(PyExc_ValueError, "isolation level must be between 0 and 4"); return NULL; } } if (0 > conn_rollback(self)) { return NULL; } if (level == 0) { if (0 > conn_set_session(self, 1, self->isolevel, self->readonly, self->deferrable)) { return NULL; } } else { if (0 > conn_set_session(self, 0, level, self->readonly, self->deferrable)) { return NULL; } } Py_RETURN_NONE; }
static PyObject * psyco_conn_set_session(connectionObject *self, PyObject *args, PyObject *kwargs) { PyObject *isolevel = Py_None; PyObject *readonly = Py_None; PyObject *deferrable = Py_None; PyObject *autocommit = Py_None; int c_isolevel = self->isolevel; int c_readonly = self->readonly; int c_deferrable = self->deferrable; int c_autocommit = self->autocommit; static char *kwlist[] = {"isolation_level", "readonly", "deferrable", "autocommit", NULL}; _set_session_checks(self, set_session); if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|OOOO", kwlist, &isolevel, &readonly, &deferrable, &autocommit)) { return NULL; } if (Py_None != isolevel) { if (0 > (c_isolevel = _psyco_conn_parse_isolevel(isolevel))) { return NULL; } } if (Py_None != readonly) { if (0 > (c_readonly = _psyco_conn_parse_onoff(readonly))) { return NULL; } } if (Py_None != deferrable) { if (0 > (c_deferrable = _psyco_conn_parse_onoff(deferrable))) { return NULL; } } if (Py_None != autocommit) { if (-1 == (c_autocommit = PyObject_IsTrue(autocommit))) { return NULL; } } if (0 > conn_set_session( self, c_autocommit, c_isolevel, c_readonly, c_deferrable)) { return NULL; } Py_RETURN_NONE; }
static int psyco_conn_deferrable_set(connectionObject *self, PyObject *pyvalue) { int value; if (!_psyco_set_session_check_setter_wrapper(self)) { return -1; } if (0 > (value = _psyco_conn_parse_onoff(pyvalue))) { return -1; } if (0 > conn_set_session(self, self->autocommit, self->isolevel, self->readonly, value)) { return -1; } return 0; }
static int psyco_conn_autocommit_set(connectionObject *self, PyObject *pyvalue) { int value; if (!_psyco_set_session_check_setter_wrapper(self)) { return -1; } if (-1 == (value = PyObject_IsTrue(pyvalue))) { return -1; } if (0 > conn_set_session(self, value, self->isolevel, self->readonly, self->deferrable)) { return -1; } return 0; }
static int psyco_conn_deferrable_set(connectionObject *self, PyObject *pyvalue) { int value; if (!_psyco_set_session_check_setter_wrapper(self)) { return -1; } if (0 > (value = _psyco_conn_parse_onoff(pyvalue))) { return -1; } if (0 > conn_set_session(self, SRV_STATE_UNCHANGED, SRV_STATE_UNCHANGED, SRV_STATE_UNCHANGED, value)) { return -1; } return 0; }
static int psyco_conn_isolation_level_set(connectionObject *self, PyObject *pyvalue) { int value; if (!_psyco_set_session_check_setter_wrapper(self)) { return -1; } if (0 > (value = _psyco_conn_parse_isolevel(pyvalue))) { return -1; } if (0 > conn_set_session(self, SRV_STATE_UNCHANGED, value, SRV_STATE_UNCHANGED, SRV_STATE_UNCHANGED)) { return -1; } return 0; }
static int psyco_conn_autocommit_set(connectionObject *self, PyObject *pyvalue) { int value; if (!_psyco_set_session_check_setter_wrapper(self)) { return -1; } if (-1 == (value = PyObject_IsTrue(pyvalue))) { return -1; } if (0 > conn_set_session(self, value, SRV_STATE_UNCHANGED, SRV_STATE_UNCHANGED, SRV_STATE_UNCHANGED)) { return -1; } return 0; }