Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: load_policy changed the old model #277

Merged
merged 1 commit into from
Nov 1, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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