Skip to content

Commit

Permalink
fix: load_policy changed the old model (#277)
Browse files Browse the repository at this point in the history
  • Loading branch information
Xhy-5000 authored Nov 1, 2022
1 parent 83fd431 commit f247231
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions casbin/core_enforcer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand All @@ -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

Expand Down

0 comments on commit f247231

Please sign in to comment.