import inspect
import sys
import types

from rmake.lib.apiutils import thaw, freeze

class NodeType(object):
    nodeType = 'UNKNOWN'
    def __init__(self):
        pass

    def freeze(self):
        return (self.nodeType, self.__dict__)

    @classmethod
    def thaw(class_, d):
        return class_(**d)

class Client(NodeType):
    nodeType = 'CLIENT'

_nodeTypes = {}
def registerNodeTypes(moduleName):
    global _nodeTypes
    for item in sys.modules[moduleName].__dict__.values():
        if inspect.isclass(item) and issubclass(item, NodeType):
            _nodeTypes[item.nodeType] = item
registerNodeTypes(__name__)

def registerNodeType(class_):
    _nodeTypes[class_.nodeType] = class_

def thawNodeType(info):
    nodeType = info[0]
    return _nodeTypes[nodeType].thaw(info[1])

@@ -82,31 +82,252 @@
 ze%0A%0A
-class NodeType(object):
+%0A_nodeTypes = %7B%7D%0Aclass _NodeTypeRegistrar(type):%0A    def __init__(self, name, bases, dict):%0A        type.__init__(self, name, bases, dict)%0A        _nodeTypes%5Bself.nodeType%5D = self%0A%0A%0Aclass NodeType(object):%0A    __metaclass__ = _NodeTypeRegistrar
 %0A   
@@ -578,351 +578,8 @@
 T'%0A%0A
-_nodeTypes = %7B%7D%0Adef registerNodeTypes(moduleName):%0A    global _nodeTypes%0A    for item in sys.modules%5BmoduleName%5D.__dict__.values():%0A        if inspect.isclass(item) and issubclass(item, NodeType):%0A            _nodeTypes%5Bitem.nodeType%5D = item%0AregisterNodeTypes(__name__)%0A%0Adef registerNodeType(class_):%0A    _nodeTypes%5Bclass_.nodeType%5D = class_%0A%0A
 def 

Use metaclasses to register node types.