~james-w/ubuntu/lucid/psycopg2/precise-backport

« back to all changes in this revision

Viewing changes to psycopg/cursor_int.c

  • Committer: Bazaar Package Importer
  • Author(s): Fabio Tranchitella, Jakub Wilk, Fabio Tranchitella
  • Date: 2011-06-19 18:25:53 UTC
  • mfrom: (5.1.10 sid)
  • Revision ID: james.westby@ubuntu.com-20110619182553-uye7z0g5ewab98px
Tags: 2.4.2-1
[ Jakub Wilk ]
* Add Debian Python Modules Team to Uploaders.

[ Fabio Tranchitella ]
* New upstream release.
* debian/watch: updated, use pypi.
* debian/control, debian/rules: switched to dh_python2.
* debian/control: bumped Standard-Version to 3.9.2, no changes required.

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
 * License for more details.
24
24
 */
25
25
 
26
 
#define PY_SSIZE_T_CLEAN
27
 
#include <Python.h>
28
 
#include <string.h>
29
 
 
30
26
#define PSYCOPG_MODULE
31
 
#include "psycopg/config.h"
32
27
#include "psycopg/psycopg.h"
 
28
 
33
29
#include "psycopg/cursor.h"
34
30
#include "psycopg/pqpath.h"
 
31
#include "psycopg/typecast.h"
 
32
 
 
33
/* curs_get_cast - return the type caster for an oid.
 
34
 *
 
35
 * Return the most specific type caster, from cursor to connection to global.
 
36
 * If no type caster is found, return the default one.
 
37
 *
 
38
 * Return a borrowed reference.
 
39
 */
 
40
 
 
41
PyObject *
 
42
curs_get_cast(cursorObject *self, PyObject *oid)
 
43
{
 
44
    PyObject *cast;
 
45
 
 
46
    /* cursor lookup */
 
47
    if (self->string_types != NULL && self->string_types != Py_None) {
 
48
        cast = PyDict_GetItem(self->string_types, oid);
 
49
        Dprintf("curs_get_cast:        per-cursor dict: %p", cast);
 
50
        if (cast) { return cast; }
 
51
    }
 
52
 
 
53
    /* connection lookup */
 
54
    cast = PyDict_GetItem(self->conn->string_types, oid);
 
55
    Dprintf("curs_get_cast:        per-connection dict: %p", cast);
 
56
    if (cast) { return cast; }
 
57
 
 
58
    /* global lookup */
 
59
    cast = PyDict_GetItem(psyco_types, oid);
 
60
    Dprintf("curs_get_cast:        global dict: %p", cast);
 
61
    if (cast) { return cast; }
 
62
 
 
63
    /* fallback */
 
64
    return psyco_default_cast;
 
65
}
 
66
 
 
67
#include <string.h>
 
68
 
35
69
 
36
70
/* curs_reset - reset the cursor to a clean state */
37
71