Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1g7gGB-0008DS-Cf for psycopg@arkaria.postgresql.org; Wed, 03 Oct 2018 12:28:11 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1g7gG8-0003xk-IH for psycopg@arkaria.postgresql.org; Wed, 03 Oct 2018 12:28:08 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1g7gG8-0003xd-9W for psycopg@lists.postgresql.org; Wed, 03 Oct 2018 12:28:08 +0000 Received: from mail.dndg.it ([178.32.136.2]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1g7gG4-0000Jb-RY for psycopg@lists.postgresql.org; Wed, 03 Oct 2018 12:28:06 +0000 Received: from [10.94.33.108] (93-50-194-114.ip153.fastwebnet.it [93.50.194.114]) by mail.dndg.it (Postfix) with ESMTPSA id 28231A02E9 for ; Wed, 3 Oct 2018 12:33:23 +0000 (UTC) Subject: Re: Integration of Psycopg with XTA To: psycopg@lists.postgresql.org References: <2001056273.7945904.1537909025251.ref@mail.yahoo.com> <2001056273.7945904.1537909025251@mail.yahoo.com> <1171000727.19526618.1537994198139@mail.yahoo.com> <2038369023.20583382.1538078255866@mail.yahoo.com> <106450562.4254785.1538510870700@mail.yahoo.com> From: Federico Di Gregorio Organization: DNDG srl Message-ID: <4d647279-19ae-75ea-83a7-b74b647c79bd@dndg.it> Date: Wed, 3 Oct 2018 14:28:00 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <106450562.4254785.1538510870700@mail.yahoo.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SURBL_BLOCKED, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 10/02/2018 10:07 PM, Christian Ferrari wrote: > Hi Federico, > I have been able to test _raw_pgconn using SWIG, as documented here > https://sourceforge.net/p/swig/mailman/message/27919299/ , the trick to > use PyCapsule and SWIG together is to specifically map the type with a > directive like this one: > > %typemap(in) PGconn * { >   $1 = (PGconn *) PyCapsule_GetPointer($input, > "psycopg2.connection._raw_pgconn"); > } > > This is interesting because PyCapsule is for sure a "clean" way to pass > the pointer from Psycopg to XTA. > > > A couple of questions to understand how to implement it as a re-usable > deliverable. > > In current branch, _raw_pgconn is a property, it's not a method, I have > to retrieve it as below: > > pgconn = rm1._raw_pgconn > xar1 = PostgresqlXaResource(pgconn, "PostgreSQL", "dbname=testdb") > > what do you think about a "getter method": > > pgconn = rm1._raw_pgconn() > > the name of the method does not really matter to me. > > _raw_pgconn() create a Capsule object that should be destroyed. Right now the getter creates a new capsule at every invocation so transforming it into a method should be straightforward. I'll do it later today so that you can test. > What do you think about a factory to create and destroy a PyCapsule that > contains the PGconn pointer? Mm. I don't understand what you need here? Can you show an example of usage? federico -- Federico Di Gregorio federico.digregorio@dndg.it DNDG srl http://dndg.it Credo fermamente che da qualche parte, in una scatola ci sia un gatto che non è vivo ne morto. Credo anche che se i fisici non si sbrigano a dargli una scatoletta, ben presto sarà solo morto. -- adattato da una frase di Sam Black Crow