public inbox for [email protected]  
help / color / mirror / Atom feed
From: Daniele Varrazzo <[email protected]>
To: Karsten Hilbert <[email protected]>
Cc: [email protected]
Subject: Re: Feature branches merged to master for 2.8 release
Date: Mon, 29 Oct 2018 12:12:56 +0000
Message-ID: <CA+mi_8bE7Z5BZ3O6Q1QxbCFtfBTthcNAaVa65GQs+sUTZbroTg@mail.gmail.com> (raw)
In-Reply-To: <[email protected]>
References: <CA+mi_8aVzn-4Ujuqg5aMduHjL1XQ3Y7sUU86s3p6shMefaPoSQ@mail.gmail.com>
	<[email protected]>
	<CA+mi_8bSZw7CAFPOKyanYVu2_AbP-+gcUd8N7oD-oisgth6o6A@mail.gmail.com>
	<[email protected]>
	<[email protected]>
	<[email protected]>
	<CA+mi_8bV4sq2HgAvMEx3ea6semu7g9pmwaW3gej4-peJHzO9Dg@mail.gmail.com>
	<[email protected]>

On Mon, Oct 29, 2018 at 10:54 AM Karsten Hilbert
<[email protected]> wrote:

> Apart from a wrapper class one can always monkey-patch
>
>         my_dbapi_instance._get_native_connection = my_dbapi_instance.get_native_connection
>
> at runtime.

True for a Python object, but not for a C extension object. But
subclassing is supported, so one would be able to do:

    >>> class MyConnection(psycopg2.extensions.connection):
    ...     _get_native_connection =
psycopg2.extensions.connection.get_native_connection
    ...
    >>> cnn = psycopg2.connect('', connection_factory=MyConnection)
    >>> ptr = cnn._get_native_connection()

-- Daniele




view thread (20+ messages)

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected], [email protected]
  Subject: Re: Feature branches merged to master for 2.8 release
  In-Reply-To: <CA+mi_8bE7Z5BZ3O6Q1QxbCFtfBTthcNAaVa65GQs+sUTZbroTg@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox