[Neo-report] r2047 vincent - /trunk/neo/node.py

nobody at svn.erp5.org nobody at svn.erp5.org
Fri Apr 30 15:43:08 CEST 2010


Author: vincent
Date: Fri Apr 30 15:43:08 2010
New Revision: 2047

Log:
Call _getClassFromNodeType rather than duplicating its code.

Modified:
    trunk/neo/node.py

Modified: trunk/neo/node.py
==============================================================================
--- trunk/neo/node.py [iso-8859-1] (original)
+++ trunk/neo/node.py [iso-8859-1] Fri Apr 30 15:43:08 2010
@@ -425,6 +425,10 @@
 
     def update(self, node_list):
         for node_type, addr, uuid, state in node_list:
+            # This should be done here (although klass might not be used in this
+            # iteration), as it raises if type is not valid.
+            klass = self._getClassFromNodeType(node_type)
+
             # lookup in current table
             node_by_uuid = self.getByUUID(uuid)
             node_by_addr = self.getByAddress(addr)
@@ -446,9 +450,6 @@
                     # exists only by address,
                     self.remove(node)
                 # don't exists, add it
-                klass = NODE_TYPE_MAPPING.get(node_type, None)
-                if klass is None:
-                    raise RuntimeError('Unknown node type')
                 node = klass(self, address=addr, uuid=uuid)
                 node.setState(state)
                 logging.debug('create node %s %s %s %s' % log_args)





More information about the Neo-report mailing list