@classmethod
def class_to_dict(cls, obj):
    '\n        Convert a non-serializable object to a dict. Partly borrowed from serpent.\n        '
    for clazz in cls.__custom_class_to_dict_registry:
        if isinstance(obj, clazz):
            return cls.__custom_class_to_dict_registry[clazz](obj)
    if (type(obj) in (set, dict, tuple, list)):
        raise ValueError((("can't serialize type " + str(obj.__class__)) + ' into a dict'))
    if hasattr(obj, '_pyroDaemon'):
        obj._pyroDaemon = None
    if isinstance(obj, BaseException):
        return {'__class__': ((obj.__class__.__module__ + '.') + obj.__class__.__name__), '__exception__': True, 'args': obj.args, 'attributes': vars(obj)}
    try:
        value = obj.__getstate__()
    except AttributeError:
        pass
    else:
        if isinstance(value, dict):
            return value
    try:
        value = dict(vars(obj))
        value['__class__'] = ((obj.__class__.__module__ + '.') + obj.__class__.__name__)
        return value
    except TypeError:
        if hasattr(obj, '__slots__'):
            value = {}
            for slot in obj.__slots__:
                value[slot] = getattr(obj, slot)
            value['__class__'] = ((obj.__class__.__module__ + '.') + obj.__class__.__name__)
            return value
        else:
            raise errors.SerializeError((((("don't know how to serialize class " + str(obj.__class__)) + ' using serializer ') + str(cls.__name__)) + '. Give it vars() or an appropriate __getstate__'))
Convert a non-serializable object to a dict. Partly borrowed from serpent.
@classmethod
def class_to_dict(cls, obj):
    '\n        \n        '
    for clazz in cls.__custom_class_to_dict_registry:
        if isinstance(obj, clazz):
            return cls.__custom_class_to_dict_registry[clazz](obj)
    if (type(obj) in (set, dict, tuple, list)):
        raise ValueError((("can't serialize type " + str(obj.__class__)) + ' into a dict'))
    if hasattr(obj, '_pyroDaemon'):
        obj._pyroDaemon = None
    if isinstance(obj, BaseException):
        return {'__class__': ((obj.__class__.__module__ + '.') + obj.__class__.__name__), '__exception__': True, 'args': obj.args, 'attributes': vars(obj)}
    try:
        value = obj.__getstate__()
    except AttributeError:
        pass
    else:
        if isinstance(value, dict):
            return value
    try:
        value = dict(vars(obj))
        value['__class__'] = ((obj.__class__.__module__ + '.') + obj.__class__.__name__)
        return value
    except TypeError:
        if hasattr(obj, '__slots__'):
            value = {}
            for slot in obj.__slots__:
                value[slot] = getattr(obj, slot)
            value['__class__'] = ((obj.__class__.__module__ + '.') + obj.__class__.__name__)
            return value
        else:
            raise errors.SerializeError((((("don't know how to serialize class " + str(obj.__class__)) + ' using serializer ') + str(cls.__name__)) + '. Give it vars() or an appropriate __getstate__'))