El 12/05/2011 16:07, Federico Di Gregorio escribió:
> On 12/05/11 12:36, Daniele Varrazzo wrote:
> [snip]
>>> Or,
>>> maybe even better, we can have 4 attributes and the set_transaction() as
>>> a shortcut:
>>>
>>> conn.autocommit
>>> conn.transaction_isolation_level
>>> conn.transaction_readonly
>>> conn.transaction_deferrable
>>> conn.set_transaction(isolation_level, autocommit, readonly, ...)
>>
>> Wow, I thought you wanted to limit the dbapi extensions :)
>
> Well, I know. But, in fact, if we introduce the possibility to set such
> parameters we also _need_ a way to retrieve them and attributes are the
> only sensible way to retrive them (a function returning a tuple is
> another way but stinks.)
>
Another way is setting transacion mode with predefined constants and
combining it with '|':
previous_mode = conn.set_transaction(psycppg2.TM_SERIALIZABLE |
psycppg2.TM_READONLY)
--
Oswaldo Hernández