187
187
//Check whether the field exists in the table.
188
188
//TODO_Performance: Do this without the useless Field information?
189
sharedptr<Field> field = self_derived->m_document->get_field((*(self_derived->m_relationship))->get_to_table(), field_name);
189
sharedptr<Field> field = self_derived->m_document->get_field((*(self_derived->m_relationship))->get_to_table(), field_name);
191
191
g_warning("RelatedRecord_tp_as_mapping_getitem: field %s not found in table %s", field_name.c_str(), (*(self_derived->m_relationship))->get_to_table().c_str());
284
284
static PyObject *
285
285
RelatedRecord_generic_aggregate(PyGlomRelatedRecord* self, PyObject *args, PyObject *kwargs, const Glib::ustring& aggregate)
287
static char *kwlist[] = { "field_name", 0 };
287
typedef const char* type_pch;
288
static type_pch kwlist[] = { "field_name", 0 };
288
289
PyObject* py_field_name = 0;
290
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O:RelatedRecord.sum", kwlist, &py_field_name))
291
if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char*)"O:RelatedRecord.sum", (char**)kwlist, &py_field_name))
293
294
if(!(PyString_Check(py_field_name)))
396
397
static PyMethodDef RelatedRecord_methods[] = {
397
{"sum", (PyCFunction)RelatedRecord_sum, METH_VARARGS | METH_KEYWORDS,
398
"Add all values of the field in the related records."
400
{"count", (PyCFunction)RelatedRecord_count, METH_VARARGS | METH_KEYWORDS,
401
"Count all values in the field in the related records."
403
{"min", (PyCFunction)RelatedRecord_min, METH_VARARGS | METH_KEYWORDS,
404
"Minimum of all values of the field in the related records."
406
{"max", (PyCFunction)RelatedRecord_max, METH_VARARGS | METH_KEYWORDS,
407
"Maximum of all values of the field in the related records."
398
{(char*)"sum", (PyCFunction)RelatedRecord_sum, METH_VARARGS | METH_KEYWORDS,
399
(char*)"Add all values of the field in the related records."
401
{(char*)"count", (PyCFunction)RelatedRecord_count, METH_VARARGS | METH_KEYWORDS,
402
(char*)"Count all values in the field in the related records."
404
{(char*)"min", (PyCFunction)RelatedRecord_min, METH_VARARGS | METH_KEYWORDS,
405
(char*)"Minimum of all values of the field in the related records."
407
{(char*)"max", (PyCFunction)RelatedRecord_max, METH_VARARGS | METH_KEYWORDS,
408
(char*)"Maximum of all values of the field in the related records."
409
410
{NULL, 0, 0, 0} /* Sentinel */
415
416
static PyTypeObject pyglom_RelatedRecordType = {
416
417
PyObject_HEAD_INIT(NULL)
418
"glom.RelatedRecord", /*tp_name*/
419
(char*)"glom.RelatedRecord", /*tp_name*/
419
420
sizeof(PyGlomRelatedRecord), /*tp_basicsize*/
420
421
0, /*tp_itemsize*/
421
422
(destructor)RelatedRecord_dealloc, /*tp_dealloc*/