Skip to content

Commit

Permalink
design a function that dumps customized object to json data, just cha…
Browse files Browse the repository at this point in the history
…nge for group class
  • Loading branch information
xiao-kong-long committed Nov 29, 2023
1 parent 6290866 commit 881a965
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/casdoor/group.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ def __init__(self):
self.type = ""
self.parentId = ""
self.isTopGroup = False
# self.users = [User]
self.users = [User]
self.title = ""
self.key = ""
# self.children = [Group]
self.children = [Group]
self.isEnabled = False

@classmethod
Expand Down Expand Up @@ -118,8 +118,8 @@ def modify_group(self, method: str, group: Group) -> Dict:
"clientSecret": self.client_secret,
}

group_info = json.dumps(group.to_dict())
# group_info = json.dumps(group.to_dict(), default=self.custom_encoder)
# group_info = json.dumps(group.to_dict())
group_info = json.dumps(group.to_dict(), default=self.custom_encoder)
r = requests.post(url, params=params, data=group_info)
response = r.json()
if response["status"] != "ok":
Expand All @@ -139,6 +139,6 @@ def delete_group(self, group: Group) -> Dict:
response = self.modify_group("delete-group", group)
return response

# def custom_encoder(self, o):
# if isinstance(o, (Group, User)):
# return o.__dict__
def custom_encoder(self, o):
if isinstance(o, (Group, User)):
return o.__dict__

0 comments on commit 881a965

Please sign in to comment.