Skip to content

Commit

Permalink
fix: load_policy changed the old model
Browse files Browse the repository at this point in the history
  • Loading branch information
Xhy-5000 committed Oct 31, 2022
1 parent 83fd431 commit debb981
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions casbin/core_enforcer.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,27 +194,26 @@ 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:

need_to_rebuild = True
for rm in self.rm_map.values():
rm.clear()

new_model.build_role_links(self.rm_map)
self.build_role_links()

self.model = new_model

Expand Down

0 comments on commit debb981

Please sign in to comment.