mirror of
https://github.com/psycopg/psycopg2.git
synced 2025-02-07 12:50:32 +03:00
Added __conform__ to all adapters.
This commit is contained in:
parent
e816aa07b6
commit
515d66cc9f
|
@ -1,7 +1,6 @@
|
||||||
2005-03-02 Federico Di Gregorio <fog@debian.org>
|
2005-03-02 Federico Di Gregorio <fog@debian.org>
|
||||||
|
|
||||||
* psycopg/adapter_binary.c (binary_conform): started to add
|
* psycopg/adapter_*.c: added __conform__ to all adapters.
|
||||||
__conform__ to all adapters.
|
|
||||||
|
|
||||||
* psycopg/adapter_qstring.c (qstring_quote): we now use
|
* psycopg/adapter_qstring.c (qstring_quote): we now use
|
||||||
PyString_AsStringAndSize() instead of strlen() that would stop at
|
PyString_AsStringAndSize() instead of strlen() that would stop at
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
#include "psycopg/python.h"
|
#include "psycopg/python.h"
|
||||||
#include "psycopg/psycopg.h"
|
#include "psycopg/psycopg.h"
|
||||||
#include "psycopg/adapter_asis.h"
|
#include "psycopg/adapter_asis.h"
|
||||||
|
#include "psycopg/microprotocols_proto.h"
|
||||||
|
|
||||||
/** the AsIs object **/
|
/** the AsIs object **/
|
||||||
|
|
||||||
|
@ -52,14 +52,19 @@ asis_getquoted(asisObject *self, PyObject *args)
|
||||||
}
|
}
|
||||||
|
|
||||||
PyObject *
|
PyObject *
|
||||||
asis_prepare(asisObject *self, PyObject *args)
|
asis_conform(binaryObject *self, PyObject *args)
|
||||||
{
|
{
|
||||||
PyObject *fake;
|
PyObject *res, *proto;
|
||||||
|
|
||||||
if (!PyArg_ParseTuple(args, "O", &fake)) return NULL;
|
if (!PyArg_ParseTuple(args, "O", &proto)) return NULL;
|
||||||
|
|
||||||
Py_INCREF(Py_None);
|
if (proto == (PyObject*)&isqlquoteType)
|
||||||
return Py_None;
|
res = (PyObject*)self;
|
||||||
|
else
|
||||||
|
res = Py_None;
|
||||||
|
|
||||||
|
Py_INCREF(res);
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** the AsIs object */
|
/** the AsIs object */
|
||||||
|
@ -76,8 +81,7 @@ static struct PyMemberDef asisObject_members[] = {
|
||||||
static PyMethodDef asisObject_methods[] = {
|
static PyMethodDef asisObject_methods[] = {
|
||||||
{"getquoted", (PyCFunction)asis_getquoted, METH_VARARGS,
|
{"getquoted", (PyCFunction)asis_getquoted, METH_VARARGS,
|
||||||
"getquoted() -> wrapped object value as SQL-quoted string"},
|
"getquoted() -> wrapped object value as SQL-quoted string"},
|
||||||
/* {"prepare", (PyCFunction)asis_prepare, METH_VARARGS,
|
{"__conform__", (PyCFunction)asis_conform, METH_VARARGS, NULL},
|
||||||
"prepare(conn) -> currently does nothing"}, */
|
|
||||||
{NULL} /* Sentinel */
|
{NULL} /* Sentinel */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -32,6 +32,7 @@
|
||||||
#include "psycopg/python.h"
|
#include "psycopg/python.h"
|
||||||
#include "psycopg/psycopg.h"
|
#include "psycopg/psycopg.h"
|
||||||
#include "psycopg/adapter_datetime.h"
|
#include "psycopg/adapter_datetime.h"
|
||||||
|
#include "psycopg/microprotocols_proto.h"
|
||||||
|
|
||||||
|
|
||||||
/* the pointer to the datetime module API is initialized by the module init
|
/* the pointer to the datetime module API is initialized by the module init
|
||||||
|
@ -83,14 +84,19 @@ pydatetime_getquoted(pydatetimeObject *self, PyObject *args)
|
||||||
}
|
}
|
||||||
|
|
||||||
PyObject *
|
PyObject *
|
||||||
pydatetime_prepare(pydatetimeObject *self, PyObject *args)
|
datetime_conform(binaryObject *self, PyObject *args)
|
||||||
{
|
{
|
||||||
PyObject *fake;
|
PyObject *res, *proto;
|
||||||
|
|
||||||
if (!PyArg_ParseTuple(args, "O", &fake)) return NULL;
|
if (!PyArg_ParseTuple(args, "O", &proto)) return NULL;
|
||||||
|
|
||||||
Py_INCREF(Py_None);
|
if (proto == (PyObject*)&isqlquoteType)
|
||||||
return Py_None;
|
res = (PyObject*)self;
|
||||||
|
else
|
||||||
|
res = Py_None;
|
||||||
|
|
||||||
|
Py_INCREF(res);
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** the DateTime wrapper object **/
|
/** the DateTime wrapper object **/
|
||||||
|
@ -108,8 +114,7 @@ static struct PyMemberDef pydatetimeObject_members[] = {
|
||||||
static PyMethodDef pydatetimeObject_methods[] = {
|
static PyMethodDef pydatetimeObject_methods[] = {
|
||||||
{"getquoted", (PyCFunction)pydatetime_getquoted, METH_VARARGS,
|
{"getquoted", (PyCFunction)pydatetime_getquoted, METH_VARARGS,
|
||||||
"getquoted() -> wrapped object value as SQL date/time"},
|
"getquoted() -> wrapped object value as SQL date/time"},
|
||||||
/* {"prepare", (PyCFunction)pydatetime_prepare, METH_VARARGS,
|
{"__conform__", (PyCFunction)pydatetime_conform, METH_VARARGS, NULL},
|
||||||
"prepare(conn) -> currently does nothing"}, */
|
|
||||||
{NULL} /* Sentinel */
|
{NULL} /* Sentinel */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
#include "psycopg/python.h"
|
#include "psycopg/python.h"
|
||||||
#include "psycopg/psycopg.h"
|
#include "psycopg/psycopg.h"
|
||||||
#include "psycopg/adapter_mxdatetime.h"
|
#include "psycopg/adapter_mxdatetime.h"
|
||||||
|
#include "psycopg/microprotocols_proto.h"
|
||||||
|
|
||||||
/* the pointer to the mxDateTime API is initialized by the module init code,
|
/* the pointer to the mxDateTime API is initialized by the module init code,
|
||||||
we just need to grab it */
|
we just need to grab it */
|
||||||
|
@ -59,14 +60,19 @@ mxdatetime_getquoted(mxdatetimeObject *self, PyObject *args)
|
||||||
}
|
}
|
||||||
|
|
||||||
PyObject *
|
PyObject *
|
||||||
mxdatetime_prepare(mxdatetimeObject *self, PyObject *args)
|
mxdatetime_conform(binaryObject *self, PyObject *args)
|
||||||
{
|
{
|
||||||
PyObject *fake;
|
PyObject *res, *proto;
|
||||||
|
|
||||||
if (!PyArg_ParseTuple(args, "O", &fake)) return NULL;
|
if (!PyArg_ParseTuple(args, "O", &proto)) return NULL;
|
||||||
|
|
||||||
Py_INCREF(Py_None);
|
if (proto == (PyObject*)&isqlquoteType)
|
||||||
return Py_None;
|
res = (PyObject*)self;
|
||||||
|
else
|
||||||
|
res = Py_None;
|
||||||
|
|
||||||
|
Py_INCREF(res);
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** the MxDateTime object **/
|
/** the MxDateTime object **/
|
||||||
|
@ -84,8 +90,7 @@ static struct PyMemberDef mxdatetimeObject_members[] = {
|
||||||
static PyMethodDef mxdatetimeObject_methods[] = {
|
static PyMethodDef mxdatetimeObject_methods[] = {
|
||||||
{"getquoted", (PyCFunction)mxdatetime_getquoted, METH_VARARGS,
|
{"getquoted", (PyCFunction)mxdatetime_getquoted, METH_VARARGS,
|
||||||
"getquoted() -> wrapped object value as SQL date/time"},
|
"getquoted() -> wrapped object value as SQL date/time"},
|
||||||
/* {"prepare", (PyCFunction)mxdatetime_prepare, METH_VARARGS,
|
{"__conform__", (PyCFunction)mxdatetime_conform, METH_VARARGS, NULL},
|
||||||
"prepare(conn) -> currently does nothing"}, */
|
|
||||||
{NULL} /* Sentinel */
|
{NULL} /* Sentinel */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
#include "psycopg/python.h"
|
#include "psycopg/python.h"
|
||||||
#include "psycopg/psycopg.h"
|
#include "psycopg/psycopg.h"
|
||||||
#include "psycopg/adapter_pboolean.h"
|
#include "psycopg/adapter_pboolean.h"
|
||||||
|
#include "psycopg/microprotocols_proto.h"
|
||||||
|
|
||||||
|
|
||||||
/** the Boolean object **/
|
/** the Boolean object **/
|
||||||
|
@ -52,14 +53,19 @@ pboolean_getquoted(pbooleanObject *self, PyObject *args)
|
||||||
}
|
}
|
||||||
|
|
||||||
PyObject *
|
PyObject *
|
||||||
pboolean_prepare(pbooleanObject *self, PyObject *args)
|
pboolean_conform(binaryObject *self, PyObject *args)
|
||||||
{
|
{
|
||||||
PyObject *fake;
|
PyObject *res, *proto;
|
||||||
|
|
||||||
if (!PyArg_ParseTuple(args, "O", &fake)) return NULL;
|
if (!PyArg_ParseTuple(args, "O", &proto)) return NULL;
|
||||||
|
|
||||||
Py_INCREF(Py_None);
|
if (proto == (PyObject*)&isqlquoteType)
|
||||||
return Py_None;
|
res = (PyObject*)self;
|
||||||
|
else
|
||||||
|
res = Py_None;
|
||||||
|
|
||||||
|
Py_INCREF(res);
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** the Boolean object */
|
/** the Boolean object */
|
||||||
|
@ -76,8 +82,7 @@ static struct PyMemberDef pbooleanObject_members[] = {
|
||||||
static PyMethodDef pbooleanObject_methods[] = {
|
static PyMethodDef pbooleanObject_methods[] = {
|
||||||
{"getquoted", (PyCFunction)pboolean_getquoted, METH_VARARGS,
|
{"getquoted", (PyCFunction)pboolean_getquoted, METH_VARARGS,
|
||||||
"getquoted() -> wrapped object value as SQL-quoted string"},
|
"getquoted() -> wrapped object value as SQL-quoted string"},
|
||||||
/* {"prepare", (PyCFunction)pboolean_prepare, METH_VARARGS,
|
{"__conform__", (PyCFunction)pboolean_conform, METH_VARARGS, NULL},
|
||||||
"prepare(conn) -> currently does nothing"}, */
|
|
||||||
{NULL} /* Sentinel */
|
{NULL} /* Sentinel */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -32,6 +32,7 @@
|
||||||
#include "psycopg/psycopg.h"
|
#include "psycopg/psycopg.h"
|
||||||
#include "psycopg/connection.h"
|
#include "psycopg/connection.h"
|
||||||
#include "psycopg/adapter_qstring.h"
|
#include "psycopg/adapter_qstring.h"
|
||||||
|
#include "psycopg/microprotocols_proto.h"
|
||||||
|
|
||||||
|
|
||||||
/** the quoting code */
|
/** the quoting code */
|
||||||
|
@ -183,6 +184,21 @@ qstring_prepare(qstringObject *self, PyObject *args)
|
||||||
return Py_None;
|
return Py_None;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PyObject *
|
||||||
|
qstring_conform(binaryObject *self, PyObject *args)
|
||||||
|
{
|
||||||
|
PyObject *res, *proto;
|
||||||
|
|
||||||
|
if (!PyArg_ParseTuple(args, "O", &proto)) return NULL;
|
||||||
|
|
||||||
|
if (proto == (PyObject*)&isqlquoteType)
|
||||||
|
res = (PyObject*)self;
|
||||||
|
else
|
||||||
|
res = Py_None;
|
||||||
|
|
||||||
|
Py_INCREF(res);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
/** the QuotedString object **/
|
/** the QuotedString object **/
|
||||||
|
|
||||||
|
@ -202,6 +218,7 @@ static PyMethodDef qstringObject_methods[] = {
|
||||||
"getquoted() -> wrapped object value as SQL-quoted string"},
|
"getquoted() -> wrapped object value as SQL-quoted string"},
|
||||||
{"prepare", (PyCFunction)qstring_prepare, METH_VARARGS,
|
{"prepare", (PyCFunction)qstring_prepare, METH_VARARGS,
|
||||||
"prepare(conn) -> set encoding to conn->encoding"},
|
"prepare(conn) -> set encoding to conn->encoding"},
|
||||||
|
{"__conform__", (PyCFunction)qstring_conform, METH_VARARGS, NULL},
|
||||||
{NULL} /* Sentinel */
|
{NULL} /* Sentinel */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user