def check_ownership(obj, raise_if_false=True):
 if (not obj):
  return False
 security_exception = utils.SupersetSecurityException(u"You don't have the rights to alter [{}]".format(obj))
 if g.user.is_anonymous():
  if raise_if_false:
   raise security_exception
  return False
 roles = (r.name for r in get_user_roles())
 if (u'Admin' in roles):
  return True
 session = db.create_scoped_session()
 orig_obj = session.query(obj.__class__).filter_by(id=obj.id).first()
 owner_names = (user.username for user in orig_obj.owners)
 if (hasattr(orig_obj, u'created_by') and orig_obj.created_by and (orig_obj.created_by.username == g.user.username)):
  return True
 if (hasattr(orig_obj, u'owners') and g.user and hasattr(g.user, u'username') and (g.user.username in owner_names)):
  return True
 if raise_if_false:
  raise security_exception
 else:
  return False

def check_ownership ( obj , raise_if_false = True ) : if ( not obj ) : return False security_exception = utils . SupersetSecurityException ( u"You don't have the rights to alter [{}]" . format ( obj ) ) if g . user . is_anonymous ( ) : if raise_if_false : raise security_exception return False roles = ( r . name for r in get_user_roles ( ) ) if ( u'Admin' in roles ) : return True session = db . create_scoped_session ( ) orig_obj = session . query ( obj . __class__ ) . filter_by ( id = obj . id ) . first ( ) owner_names = ( user . username for user in orig_obj . owners ) if ( hasattr ( orig_obj , u'created_by' ) and orig_obj . created_by and ( orig_obj . created_by . username == g . user . username ) ) : return True if ( hasattr ( orig_obj , u'owners' ) and g . user and hasattr ( g . user , u'username' ) and ( g . user . username in owner_names ) ) : return True if raise_if_false : raise security_exception else : return False
a convenience function .