Univention Bugzilla – Bug 50485
UDM REST Client: Minor issues
Last modified: 2021-09-10 09:17:49 CEST
Some unrelated issues I found when using the new rest client "univention.admin.rest.client". I could open one bug per issue, but maybe this is easier: 1) I need the ldap/base from the server. I found no trivial way of doing this, although I think it is a common task. udm.get_ldap_base() would be nice to have. 2) Object.uri may give a traceback, presumably when the object does not yet exist >>> user = udm.get('users/user').new() >>> user.uri Traceback (most recent call last): File "<stdin>", line 1, in <module> File "univention/admin/rest/client/__init__.py", line 447, in uri uri = self.client.get_relation(self.hal, 'self') File "univention/admin/rest/client/__init__.py", line 225, in get_relation return next(self.get_relations(entry, relation, name, template)) StopIteration 3) The method _reload_from_response uses a variable that is just not defined: "reload". Funnily enough, this still works in Python 2.7 because reload is a builtin, making "if reload" always True. But in Python 3 this gives a traceback. 4) If a URI is used that is not a UDM REST API's endpoint, I saw a traceback: univention.admin.rest.client.UDM.http('http://localhost/univention/udm/', 'Administrator', 'univention').get('users/user') works as expected. Now if I give a wrong uri, it should not work. But instead of a readable error message, I get this: univention.admin.rest.client.UDM.http('http://localhost/', 'Administrator', 'univention').get('users/user') Traceback (most recent call last): File "<stdin>", line 1, in <module> File "univention/admin/rest/client/__init__.py", line 288, in get for module in self.modules(name): File "univention/admin/rest/client/__init__.py", line 271, in modules for module in self.client.resolve_relations(self.entry, 'udm:object-modules'): File "univention/admin/rest/client/__init__.py", line 228, in resolve_relations embedded = entry.get('_embedded', {}) AttributeError: 'unicode' object has no attribute 'get' "entry" here is the HTML from /univention/portal/index.html 5) During code inspection, I found that "make_request" has a loop built in that retries during ServiceUnavailable. But the way it is implemented I do not think this works. The last line in the except clause does a "return doit()" again. I guess this needs to be removed?
Thanks. All points adressed in git:fbest/50485-rest-client-errors.
This was already fixed during Python 3 Migration in Bug #51685.