def soft_delete_aware_query(context, *args, **kwargs):
 query = context.session.query(*args)
 show_deleted = (kwargs.get('show_deleted') or context.show_deleted)
 if (not show_deleted):
  query = query.filter_by(deleted_at=None)
 return query

def soft_delete_aware_query ( context , * args , ** kwargs ) : query = context . session . query ( * args ) show_deleted = ( kwargs . get ( 'show_deleted' ) or context . show_deleted ) if ( not show_deleted ) : query = query . filter_by ( deleted_at = None ) return query
stack query helper that accounts for contexts show_deleted field .