__str__() split into __str__() and __repr__(). RemoteItem param is str()ified before use.

2019-08-17
Marnanel Thurman 2019-05-29 01:08:07 +01:00
rodzic d4a1b5707c
commit a96d2a2a85
1 zmienionych plików z 10 dodań i 4 usunięć

Wyświetl plik

@ -11,7 +11,7 @@ logger = logging.getLogger(name='django_kepi')
class RemoteItem(dict):
def __init__(self, body):
self.update(json.loads(body))
self.update(json.loads(str(body)))
class CachedRemoteText(models.Model):
@ -29,10 +29,16 @@ class CachedRemoteText(models.Model):
return self.content is None
def __str__(self):
if self.key is None:
return '(%s: "%s")' % (self.owner, self.content[:20])
if self.content is not None:
return self.content
else:
return '(%s is GONE)' % (self.owner)
return ''
def __repr__(self):
if self.content is not None:
return '(%s: "%s")' % (self.address, self.content[:20])
else:
return '(%s is GONE)' % (self.address)
@classmethod
def fetch(cls,