Decorator for serializers.

    A serializer should accept two parameters: An object and a path which is
    a directory on the filesystem where supplementary data can be stored. This
    is most often useful for datasources. It should return a dictionary version
    of the original object that contains only elements that can be serialized
    to json.

def serializer(_type):
    """
    Decorator for serializers.

    A serializer should accept two parameters: An object and a path which is
    a directory on the filesystem where supplementary data can be stored. This
    is most often useful for datasources. It should return a dictionary version
    of the original object that contains only elements that can be serialized
    to json.
    """

    def inner(func):
        name = dr.get_name(_type)
        if name in SERIALIZERS:
            msg = "%s already has a serializer registered: %s"
            raise Exception(msg % (name, dr.get_name(SERIALIZERS[name])))
        SERIALIZERS[name] = func
        return func
    return inner