Skip to content
Snippets Groups Projects
Unverified Commit 2e8e2ce9 authored by Timm Fitschen's avatar Timm Fitschen
Browse files

Merge branch 'f-server-side-scripting' into f-anonymous-user

parents 50a24b3a cfb0de7e
No related branches found
No related tags found
No related merge requests found
<!--THIS FILE HAS BEEN GENERATED BY A SCRIPT. PLEASE DON'T CHANGE IT MANUALLY.-->
# Welcome
This is the **CaosDB Python Client Library** repository and a part of the
......
......@@ -219,6 +219,7 @@ def _delete_role(name, **kwargs):
def _set_roles(username, roles, realm=None, **kwargs):
xml = etree.Element("Roles")
print(roles)
for r in roles:
xml.append(etree.Element("Role", name=r))
......@@ -254,8 +255,9 @@ def _get_roles(username, realm=None, **kwargs):
e.msg = "User does not exist."
raise
ret = set()
for r in etree.fromstring(body)[0]:
ret.add(r.get("name"))
for r in etree.fromstring(body).xpath('/Response/Roles')[0]:
if r.tag == "Role":
ret.add(r.get("name"))
return ret
......@@ -316,11 +318,12 @@ class PermissionRule():
xml = etree.fromstring(body)
ret = set()
for c in xml:
ret.add(PermissionRule._parse_element(c))
if c.tag in ["Grant", "Deny"]:
ret.add(PermissionRule._parse_element(c))
return ret
def __str__(self):
return self._action + "(" + self._permission + ")" + \
return str(self._action) + "(" + str(self._permission) + ")" + \
("P" if self._priority is True else "")
def __repr__(self):
......
......@@ -70,9 +70,10 @@ class ClientErrorException(CaosDBException):
class ServerErrorException(CaosDBException):
def __init__(self, body):
xml = etree.fromstring(body)
msg = xml[0].get("description")
if xml[0].text is not None:
msg = msg + "\n\n" + xml[0].text
error = xml.xpath('/Response/Error')[0]
msg = error.get("description")
if error.text is not None:
msg = msg + "\n\n" + error.text
CaosDBException.__init__(self, msg)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment