def action_handler(verb, **kwargs):
 kwargs.pop('signal', None)
 actor = kwargs.pop('sender')
 if hasattr(verb, '_proxy____args'):
  verb = verb._proxy____args[0]
 newaction = get_model('actstream', 'action')(actor_content_type=ContentType.objects.get_for_model(actor), actor_object_id=actor.pk, verb=text_type(verb), public=bool(kwargs.pop('public', True)), description=kwargs.pop('description', None), timestamp=kwargs.pop('timestamp', now()))
 for opt in ('target', 'action_object'):
  obj = kwargs.pop(opt, None)
  if (obj is not None):
   check(obj)
   setattr(newaction, ('%s_object_id' % opt), obj.pk)
   setattr(newaction, ('%s_content_type' % opt), ContentType.objects.get_for_model(obj))
 if (settings.USE_JSONFIELD and len(kwargs)):
  newaction.data = kwargs
 newaction.save(force_insert=True)
 return newaction

def action_handler ( verb , ** kwargs ) : kwargs . pop ( 'signal' , None ) actor = kwargs . pop ( 'sender' ) if hasattr ( verb , '_proxy____args' ) : verb = verb . _proxy____args [ 0 ] newaction = get_model ( 'actstream' , 'action' ) ( actor_content_type = ContentType . objects . get_for_model ( actor ) , actor_object_id = actor . pk , verb = text_type ( verb ) , public = bool ( kwargs . pop ( 'public' , True ) ) , description = kwargs . pop ( 'description' , None ) , timestamp = kwargs . pop ( 'timestamp' , now ( ) ) ) for opt in ( 'target' , 'action_object' ) : obj = kwargs . pop ( opt , None ) if ( obj is not None ) : check ( obj ) setattr ( newaction , ( '%s_object_id' % opt ) , obj . pk ) setattr ( newaction , ( '%s_content_type' % opt ) , ContentType . objects . get_for_model ( obj ) ) if ( settings . USE_JSONFIELD and len ( kwargs ) ) : newaction . data = kwargs newaction . save ( force_insert = True ) return newaction
function to wrap calls to make actions on firewalld in try/except logic and emit useful error messages .