def groups_for_user(environ, username):
 UserModel = auth.get_user_model()
 db.reset_queries()
 try:
  try:
   user = UserModel._default_manager.get_by_natural_key(username)
  except UserModel.DoesNotExist:
   return []
  if (not user.is_active):
   return []
  return [force_bytes(group.name) for group in user.groups.all()]
 finally:
  db.close_old_connections()

def groups_for_user ( environ , username ) : UserModel = auth . get_user_model ( ) db . reset_queries ( ) try : try : user = UserModel . _default_manager . get_by_natural_key ( username ) except UserModel . DoesNotExist : return [ ] if ( not user . is_active ) : return [ ] return [ force_bytes ( group . name ) for group in user . groups . all ( ) ] finally : db . close_old_connections ( )
authorizes a user based on groups .