def sync_role_definitions():
 logging.info(u'Syncing role definition')
 get_or_create_main_db()
 create_custom_permissions()
 pvms = db.session.query(ab_models.PermissionView).all()
 pvms = [p for p in pvms if (p.permission and p.view_menu)]
 pvms_to_delete = [p for p in pvms if (not (p.permission and p.view_menu))]
 for pvm_to_delete in pvms_to_delete:
  sm.get_session.delete(pvm_to_delete)
 set_role(u'Admin', pvms, is_admin_pvm)
 set_role(u'Alpha', pvms, is_alpha_pvm)
 set_role(u'Gamma', pvms, is_gamma_pvm)
 set_role(u'granter', pvms, is_granter_pvm)
 set_role(u'sql_lab', pvms, is_sql_lab_pvm)
 if conf.get(u'PUBLIC_ROLE_LIKE_GAMMA', False):
  set_role(u'Public', pvms, is_gamma_pvm)
 view_menu_set = db.session.query(models.SqlaTable).all()
 create_missing_datasource_perms(view_menu_set)
 create_missing_database_perms(view_menu_set)
 create_missing_metrics_perm(view_menu_set)
 sm.get_session.commit()

def sync_role_definitions ( ) : logging . info ( u'Syncing role definition' ) get_or_create_main_db ( ) create_custom_permissions ( ) pvms = db . session . query ( ab_models . PermissionView ) . all ( ) pvms = [ p for p in pvms if ( p . permission and p . view_menu ) ] pvms_to_delete = [ p for p in pvms if ( not ( p . permission and p . view_menu ) ) ] for pvm_to_delete in pvms_to_delete : sm . get_session . delete ( pvm_to_delete ) set_role ( u'Admin' , pvms , is_admin_pvm ) set_role ( u'Alpha' , pvms , is_alpha_pvm ) set_role ( u'Gamma' , pvms , is_gamma_pvm ) set_role ( u'granter' , pvms , is_granter_pvm ) set_role ( u'sql_lab' , pvms , is_sql_lab_pvm ) if conf . get ( u'PUBLIC_ROLE_LIKE_GAMMA' , False ) : set_role ( u'Public' , pvms , is_gamma_pvm ) view_menu_set = db . session . query ( models . SqlaTable ) . all ( ) create_missing_datasource_perms ( view_menu_set ) create_missing_database_perms ( view_menu_set ) create_missing_metrics_perm ( view_menu_set ) sm . get_session . commit ( )
inits the superset application with security roles and such .