"""
Utils for dealing with Nodes/Plugins.
"""

import json
import node
import types



class NodeEncoder(json.JSONEncoder):
    """
    Encoder for JSONifying nodes.
    """
    def default(self, n):
        """
        Flatten node.
        """
        # FIXME: issubclass doesn't work because the
        # qualified module names don't match.  Work
        # out why and remove this hack.
        nbases = []
        if type(n) == types.TypeType:
            nbases = [b for b in n.__mro__ if \
                    b.__name__.find("Node") != -1]
        if len(nbases) > 0:
            return dict(
                name=n.name,
                description=n.description,
                arity=n.arity,
                stage=n.stage,
                parameters=n.parameters(),
            )
        return super(NodeEncoder, self).default(n)            





@@ -229,350 +229,75 @@
 node
-.%0A        %22%22%22%0A        # FIXME: issubclass doesn't work because the%0A        # qualified module names don't match.  Work%0A        # out why and remove this hack.%0A        nbases = %5B%5D%0A        if type(n) == types.TypeType:%0A            nbases = %5Bb for b in n.__mro__ if %5C%0A                    b.__name__.find(%22Node%22) != -1%5D%0A        if len(nbases) %3E 0
+ for JSON encoding.%0A        %22%22%22%0A        if issubclass(n, node.Node)
 :%0A  

Remove apparently-now-not-needed hack for determining JSON-encoding of derived classes. I guess this was fixed by fixing the import ambiguities