From c6744b09998efc4508c3c1d19266e0d9a2fc6652 Mon Sep 17 00:00:00 2001 From: Marnanel Thurman Date: Wed, 22 May 2019 17:40:23 +0100 Subject: [PATCH] RemoteItem made into a subclass of dict, which makes everything simpler. The local_only param of find() made optional. --- django_kepi/find.py | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/django_kepi/find.py b/django_kepi/find.py index 12a7bbb..accf4a2 100644 --- a/django_kepi/find.py +++ b/django_kepi/find.py @@ -9,24 +9,9 @@ import json logger = logging.getLogger(name='django_kepi') -class RemoteItem(object): +class RemoteItem(dict): def __init__(self, body): - self.content = json.loads(body) - logger.debug('RemoteItem created') - - def __getitem__(self, key): - return self.content[key] - - def __contains__(self, item): - return item in self.content - - def __str__(self): - return str(self.content) - - # XXX this is specific to actors! - @property - def public_key(self): - return self.content['publicKey']['publicKeyPem'] + self.update(json.loads(body)) class CachedRemoteText(models.Model): @@ -186,7 +171,7 @@ def is_local(url): return parsed_url.hostname in settings.ALLOWED_HOSTS def find(url, - local_only): + local_only=False): """ Finds an object.