[DB-SIG] Use of context managers with DB API 2

2012-11-01 Thread Christoph Zwerschke
We're currently preparing a new release of PyGreSQL and want to make use of context managers. My obvious idea was to let connections and cursors act as context managers that just close themselves, and add an extra context manager in form of a "transaction" property on the connection object that

Re: [DB-SIG] Use of context managers with DB API 2

2012-11-01 Thread Michael Bayer
On Nov 1, 2012, at 10:01 AM, Christoph Zwerschke wrote: > We're currently preparing a new release of PyGreSQL and want to make use of > context managers. My obvious idea was to let connections and cursors act as > context managers that just close themselves, and add an extra context manager >

Re: [DB-SIG] Use of context managers with DB API 2

2012-11-01 Thread M.-A. Lemburg
Christoph Zwerschke wrote: > We're currently preparing a new release of PyGreSQL and want to make use of > context managers. My > obvious idea was to let connections and cursors act as context managers that > just close themselves, > and add an extra context manager in form of a "transaction" pro

Re: [DB-SIG] Use of context managers with DB API 2

2012-11-01 Thread Chris Clark
On Thursday 2012-11-01 08:57 (-0700), M.-A. Lemburg wrote: Christoph Zwerschke wrote: We're currently preparing a new release of PyGreSQL and want to make use of context managers. My obvious idea was to let connections and cursors act as context managers that just close themselves, and add a

Re: [DB-SIG] Use of context managers with DB API 2

2012-11-01 Thread Vernon Cole
I've been scratching my head over this question, too. Someone (Christoph?) please craft for us a little sample program, as small as possible, showing how this ought to look in practice. It ought to be obvious (see PEP 20 aphorism 13) but I am in need of a Dutch person (see PEP 20 aphorism 14) to