[Neo-report] r2250 vincent - in /trunk/neo: client/ client/handlers/ tests/client/

nobody at svn.erp5.org nobody at svn.erp5.org
Sat Aug 28 09:38:41 CEST 2010


Author: vincent
Date: Sat Aug 28 09:38:41 2010
New Revision: 2250

Log:
Replace error code with exception for oidNotFound.

Also, fix _load error message, as only data inconsistency can lead to -1
error code now (and it is set locally).

Modified:
    trunk/neo/client/app.py
    trunk/neo/client/handlers/storage.py
    trunk/neo/tests/client/testStorageHandler.py

Modified: trunk/neo/client/app.py
==============================================================================
--- trunk/neo/client/app.py [iso-8859-1] (original)
+++ trunk/neo/client/app.py [iso-8859-1] Sat Aug 28 09:38:41 2010
@@ -462,10 +462,6 @@ class Application(object):
             except ConnectionClosed:
                 continue
 
-            if self.local_var.asked_object == -1:
-                # OID not found
-                break
-
             # Check data
             noid, start_serial, end_serial, compression, checksum, data \
                 = self.local_var.asked_object
@@ -491,8 +487,7 @@ class Application(object):
             raise NEOStorageError('connection failure')
 
         if self.local_var.asked_object == -1:
-            # We didn't got any object from all storage node
-            raise NEOStorageNotFoundError('oid %s not found' % (dump(oid), ))
+            raise NEOStorageError('inconsistent data')
 
         # Uncompress data
         if compression:
@@ -852,13 +847,13 @@ class Application(object):
                     undone_tid))
             except ConnectionClosed:
                 continue
-
-            if self.local_var.txn_info == -1:
+            except NEOStorageNotFoundError:
                 # Tid not found, try with next node
                 logging.warning('Transaction %s was not found on node %s',
                     dump(undone_tid), self.nm.getByAddress(conn.getAddress()))
                 continue
-            elif isinstance(self.local_var.txn_info, dict):
+
+            if isinstance(self.local_var.txn_info, dict):
                 break
             else:
                 raise NEOStorageError('undo failed')

Modified: trunk/neo/client/handlers/storage.py
==============================================================================
--- trunk/neo/client/handlers/storage.py [iso-8859-1] (original)
+++ trunk/neo/client/handlers/storage.py [iso-8859-1] Sat Aug 28 09:38:41 2010
@@ -22,7 +22,7 @@ from neo import logging
 from neo.client.handlers import BaseHandler, AnswerBaseHandler
 from neo.protocol import NodeTypes, ProtocolError, LockState
 from neo.util import dump
-from neo.client.exception import NEOStorageError
+from neo.client.exception import NEOStorageError, NEOStorageNotFoundError
 
 class StorageEventHandler(BaseHandler):
 
@@ -114,8 +114,7 @@ class StorageAnswersHandler(AnswerBaseHa
         # This can happen either when :
         # - loading an object
         # - asking for history
-        self.app.local_var.asked_object = -1
-        self.app.local_var.history = -1
+        raise NEOStorageNotFoundError(message)
 
     def tidNotFound(self, conn, message):
         # This can happen when requiring txn informations

Modified: trunk/neo/tests/client/testStorageHandler.py
==============================================================================
--- trunk/neo/tests/client/testStorageHandler.py [iso-8859-1] (original)
+++ trunk/neo/tests/client/testStorageHandler.py [iso-8859-1] Sat Aug 28 09:38:41 2010
@@ -21,7 +21,7 @@ from neo.tests import NeoTestBase
 from neo.protocol import NodeTypes, LockState
 from neo.client.handlers.storage import StorageBootstrapHandler, \
        StorageAnswersHandler
-from neo.client.exception import NEOStorageError
+from neo.client.exception import NEOStorageError, NEOStorageNotFoundError
 from ZODB.POSException import ConflictError
 
 MARKER = []
@@ -215,9 +215,8 @@ class StorageAnswerHandlerTests(NeoTestB
 
     def test_oidNotFound(self):
         conn = self.getConnection()
-        self.handler.oidNotFound(conn, 'message')
-        self.assertEqual(self.app.local_var.asked_object, -1)
-        self.assertEqual(self.app.local_var.history, -1)
+        self.assertRaises(NEOStorageNotFoundError, self.handler.oidNotFound,
+            conn, 'message')
         
     def test_tidNotFound(self):
         conn = self.getConnection()





More information about the Neo-report mailing list