def transaction_guard(f):
 @functools.wraps(f)
 def inner(self, context, *args, **kwargs):
  if (context.session.is_active and getattr(context, 'GUARD_TRANSACTION', True)):
   raise RuntimeError((_('Method %s cannot be called within a transaction.') % f))
  return f(self, context, *args, **kwargs)
 return inner

def transaction_guard ( f ) : @ functools . wraps ( f ) def inner ( self , context , * args , ** kwargs ) : if ( context . session . is_active and getattr ( context , 'GUARD_TRANSACTION' , True ) ) : raise RuntimeError ( ( _ ( 'Method %s cannot be called within a transaction.' ) % f ) ) return f ( self , context , * args , ** kwargs ) return inner
ensures that the context passed in is not in a transaction .