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