- marked as enhancement
- changed milestone to 0.4.4
- changed component to orm
Consider adding an is_active property to the session
Since committing an inactive session raises an error in SA 0.4.3, it would be helpful to have a property that tells whether the session is active or not. This property should simply query the same property of the corresponding transaction.
A use case for this is TurboGears. See also my request on the SA mailing list.
Comments (11)
-
repo owner -
repo owner - changed status to resolved
c1363d8aca5623114d36445df4c95b6bc5b49ccb b5261fa1fb338efbbf83fb600516f183de247a58 . But note that this flag is always
True
with a transactional (in 0.5 an autocommit) session, since a new transaction is begun automatically on commit/rollback in that case. -
repo owner im not correct on that point. subtransactions, when rolled back, leave the session in a "not active" state. This most frequently occurs when a
flush()
fails, for example. -
Account Deleted - removed status
- changed status to open
Thanks for implementing this. To make this useful for TurboGears, the property should also be available in a scoped session (see patch).
-
Account Deleted - attached scoping.patch
Make is_active property available in scoped session
-
repo owner - changed milestone to 0.4.xx
MyScopedSession().is_active is an immediate workaround for now.
Just to be clear, TurboGears is calling
begin()
in one particular block of code somewhere, and thencommit()
in some totally different block of code ? That's not a spectacular pattern in the first place is there an issue just using the format above ? -
Account Deleted Ok, we're using
ScopedSession().is_active
now in TG, this works with SA 0.4.7. Can you apply the patch above anyway? I think that would be a bit nicer and maybe faster.TG wraps every controller method in a transaction with
begin()
andcommit()
, but since somebody might have already committed inside the transaction, it checks whether the transaction is still active before the final commit. -
repo owner this is approved; I'd like to add it to 0.4 and 0.5.
-
repo owner - changed status to resolved
-
Account Deleted Thanks; this is now used in [http://trac.turbogears.org/changeset/5997 TG 6b7cbe6d252f6e86e7d3f568f7e6c04e68743ddf.
-
repo owner - removed milestone
Removing milestone: 0.4.xx (automated comment)
- Log in to comment