class BaseHandler(object):
    """
    Abstract base class for handlers.
    """
    def __init__(self, base):
        """
        Initialize a new handler to handle `type`.

        :Parameters:
          - `base`: reference to pickler/unpickler

        """
        self._base = base

    def flatten(self, obj, data):
        """
        Flatten `obj` into a json-friendly form.

        :Parameters:
          - `obj`: object of `type`

        """
        raise NotImplementedError("Abstract method.")

    def restore(self, obj):
        """
        Restores the `obj` to `type`

        :Parameters:
          - `object`: json-friendly object

        """
        raise NotImplementedError("Abstract method.")


class Registry(object):
    REGISTRY = {}

    def register(self, type, handler):
        """
        Register handler.

        :Parameters:
          - `handler`: `BaseHandler` subclass

        """
        self.REGISTRY[type] = handler
        return handler

    def get(self, cls):
        """
        Get the customer handler for `obj` (if any)

        :Parameters:
          - `cls`: class to handle

        """
        return self.REGISTRY.get(cls, None)


registry = Registry()

class BaseHandler(object):
    """
    Abstract base class for handlers.
    """
    def __init__(self, base):
        """
        Initialize a new handler to handle `type`.

        :Parameters:
          - `base`: reference to pickler/unpickler

        """
        self._base = base

    def flatten(self, obj, data):
        """
        Flatten `obj` into a json-friendly form.

        :Parameters:
          - `obj`: object of `type`

        """
        raise NotImplementedError("Abstract method.")

    def restore(self, obj):
        """
        Restores the `obj` to `type`

        :Parameters:
          - `object`: json-friendly object

        """
        raise NotImplementedError("Abstract method.")


class Registry(object):
    REGISTRY = {}

    def register(self, cls, handler):
        """
        Register handler.

        :Parameters:
          - `cls`: Object class
          - `handler`: `BaseHandler` subclass

        """
        self.REGISTRY[cls] = handler
        return handler

    def get(self, cls):
        """
        Get the customer handler for `obj` (if any)

        :Parameters:
          - `cls`: class to handle

        """
        return self.REGISTRY.get(cls, None)


registry = Registry()

Remove usage of built-in 'type' name
jsonpickle.handler: Remove usage of built-in 'type' name

'type' is a built-in function so use 'cls' instead of 'type'.

Signed-off-by: David Aguilar <9de348c050f7cd1ca590883733c4e531ce610bf4@gmail.com>
