1313# limitations under the License.
1414from casbin .async_internal_enforcer import AsyncInternalEnforcer
1515from casbin .model .policy_op import PolicyOp
16+ from casbin .constant .constants import ACTION_INDEX , SUBJECT_INDEX , OBJECT_INDEX
1617
1718
1819class AsyncManagementEnforcer (AsyncInternalEnforcer ):
@@ -22,27 +23,30 @@ class AsyncManagementEnforcer(AsyncInternalEnforcer):
2223
2324 def get_all_subjects (self ):
2425 """gets the list of subjects that show up in the current policy."""
25- return self .get_all_named_subjects ("p" )
26+ return self .model . get_values_for_field_in_policy_all_types_by_name ("p" , SUBJECT_INDEX )
2627
2728 def get_all_named_subjects (self , ptype ):
2829 """gets the list of subjects that show up in the current named policy."""
29- return self .model .get_values_for_field_in_policy ("p" , ptype , 0 )
30+ field_index = self .model .get_field_index (ptype , SUBJECT_INDEX )
31+ return self .model .get_values_for_field_in_policy ("p" , ptype , field_index )
3032
3133 def get_all_objects (self ):
3234 """gets the list of objects that show up in the current policy."""
33- return self .get_all_named_objects ("p" )
35+ return self .model . get_values_for_field_in_policy_all_types_by_name ("p" , OBJECT_INDEX )
3436
3537 def get_all_named_objects (self , ptype ):
3638 """gets the list of objects that show up in the current named policy."""
37- return self .model .get_values_for_field_in_policy ("p" , ptype , 1 )
39+ field_index = self .model .get_field_index (ptype , OBJECT_INDEX )
40+ return self .model .get_values_for_field_in_policy ("p" , ptype , field_index )
3841
3942 def get_all_actions (self ):
4043 """gets the list of actions that show up in the current policy."""
41- return self .get_all_named_actions ("p" )
44+ return self .model . get_values_for_field_in_policy_all_types_by_name ("p" , ACTION_INDEX )
4245
4346 def get_all_named_actions (self , ptype ):
4447 """gets the list of actions that show up in the current named policy."""
45- return self .model .get_values_for_field_in_policy ("p" , ptype , 2 )
48+ field_index = self .model .get_field_index (ptype , ACTION_INDEX )
49+ return self .model .get_values_for_field_in_policy ("p" , ptype , field_index )
4650
4751 def get_all_roles (self ):
4852 """gets the list of roles that show up in the current named policy."""
0 commit comments