let MutableFileNode.__repr__() return something useful even if it isn't not initialize yet

This is because I sometimes log or examine a repr of an object from a function which is being called from that object's own __init__()...
(I'm committing this patch in order to test our patch management infrastructure.)
This commit is contained in:
Zooko O'Whielacronx 2008-04-17 21:32:38 -07:00
parent 60eb3505f5
commit a504f3395f

View File

@ -70,7 +70,10 @@ class MutableFileNode:
self._serializer = defer.succeed(None)
def __repr__(self):
return "<%s %x %s %s>" % (self.__class__.__name__, id(self), self.is_readonly() and 'RO' or 'RW', hasattr(self, '_uri') and self._uri.abbrev())
if hasattr(self, '_uri'):
return "<%s %x %s %s>" % (self.__class__.__name__, id(self), self.is_readonly() and 'RO' or 'RW', self._uri.abbrev())
else:
return "<%s %x %s %s>" % (self.__class__.__name__, id(self), None, None)
def init_from_uri(self, myuri):
# we have the URI, but we have not yet retrieved the public