document: fix regressions at storage and node_descriptor
Since the introduction of __len__, the descriptors were broken for the ftp module. Fix. bzr revid: p_christ@hol.gr-20101103112605-tu6n6529mbdc18ve
This commit is contained in:
@@ -181,7 +181,8 @@ class nodefd_db(StringIO, nodes.node_descriptor):
|
||||
cr = ira_browse._cr # reuse the cursor of the browse object, just now
|
||||
cr.execute('SELECT db_datas FROM ir_attachment WHERE id = %s',(ira_browse.id,))
|
||||
data = cr.fetchone()[0]
|
||||
self._size = len(data)
|
||||
if data:
|
||||
self._size = len(data)
|
||||
StringIO.__init__(self, data)
|
||||
elif mode in ('w', 'w+'):
|
||||
StringIO.__init__(self, None)
|
||||
@@ -260,7 +261,8 @@ class nodefd_db64(StringIO, nodes.node_descriptor):
|
||||
|
||||
if mode in ('r', 'r+'):
|
||||
data = base64.decodestring(ira_browse.db_datas)
|
||||
self._size = len(data)
|
||||
if data:
|
||||
self._size = len(data)
|
||||
StringIO.__init__(self, data)
|
||||
elif mode in ('w', 'w+'):
|
||||
StringIO.__init__(self, None)
|
||||
|
||||
@@ -181,6 +181,14 @@ class node_descriptor(object):
|
||||
def __len__(self):
|
||||
return self.size()
|
||||
|
||||
def __nonzero__(self):
|
||||
""" Ensure that a node_descriptor will never equal False
|
||||
|
||||
Since we do define __len__ and __iter__ for us, we must avoid
|
||||
being regarded as non-true objects.
|
||||
"""
|
||||
return True
|
||||
|
||||
def next(self, str):
|
||||
raise NotImplementedError
|
||||
|
||||
|
||||
Reference in New Issue
Block a user