> > -Dennis run_with_transaction is a generic function you can specialize to fit
> your needs, for example:
>
> from turbogears.database import run_with_transaction, _use_sa
>
> @run_with_transaction.when("getattr(func, '_no_trans', False) and
> _use_sa()")
> def _no_trans_for_this_method(func, *args, **kw):
>         return func(*args, **kw)
>
> Now in any controller method you can set a _no_trans attribute to
> True so this specialized version which doesn't start a session or
> begins any transaction runs when run_with_transaction is called:
>

This is a nice approach to this problem.  I learned how generic
functions work and checked out how run_with_transaction is implemented
using that concept.

There is one issue though, when using the approach mentioned, my
_no_trans_ method still isn't called.  The _use_sa() function returns
another the sa_rwt method because it evaluates to true before this rule
is evaluated.  I see an implementation for Ordered generic functions in
the genericfunctions.py file but that method is not being used by
run_with_transaction.

If I could call:

@run_with_transaction("getattr(func,"_no_trans",False) and
_use_sa()",order=0)

Then this would work I believe.

Should TG be patched to handle this or am I missing something?
Thanks

-Dennis


--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups 
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to