From 0bec2dd8c14a85fec0fd939b99c22e862c81229f Mon Sep 17 00:00:00 2001 From: Xhy-5000 <118010339@link.cuhk.edu.cn> Date: Thu, 27 Oct 2022 18:13:59 -0400 Subject: [PATCH] fix: load_policy changed the old model --- casbin/core_enforcer.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/casbin/core_enforcer.py b/casbin/core_enforcer.py index a4280678..f9531438 100644 --- a/casbin/core_enforcer.py +++ b/casbin/core_enforcer.py @@ -194,18 +194,18 @@ def init_rm_map(self): def load_policy(self): """reloads the policy from file/database.""" need_to_rebuild = False - new_model = copy.copy(self.model) + new_model = copy.deepcopy(self.model) new_model.clear_policy() try: self.adapter.load_policy(new_model) - self.model.sort_policies_by_subject_hierarchy() + new_model.sort_policies_by_subject_hierarchy() new_model.sort_policies_by_priority() - self.model.print_policy() + new_model.print_policy() if self.auto_build_role_links: @@ -214,7 +214,6 @@ def load_policy(self): rm.clear() new_model.build_role_links(self.rm_map) - self.build_role_links() self.model = new_model