add a __repr__ method to StorableObject
It reports the name of the class, the id and if possible a display name.
This commit is contained in:
parent
e4a9e5e72d
commit
8899e59ce3
|
@ -538,3 +538,11 @@ class StorableObject(object):
|
|||
shutil.rmtree(tmpdir)
|
||||
wipe = classmethod(wipe)
|
||||
|
||||
def __repr__(self):
|
||||
if hasattr(self, 'display_name'):
|
||||
display_name = '%r ' % self.display_name
|
||||
elif hasattr(self, 'get_display_name'):
|
||||
display_name = '%r ' % self.get_display_name()
|
||||
else:
|
||||
display_name = ''
|
||||
return '<%s %sid:%s>' % (self.__class__.__name__, display_name, self.id)
|
||||
|
|
Loading…
Reference in New Issue