# Path: riak/datatypes/errors.py
# class ContextRequired(RiakError):
#     """
#     This exception is raised when removals of map fields and set
#     entries are attempted and the datatype hasn't been initialized
#     with a context.
#     """
# 
#     _default_message = ("A context is required for remove operations, "
#                         "fetch the datatype first")
# 
#     def __init__(self, message=None):
#         super(ContextRequired, self).__init__(message or
#                                               self._default_message)
# 
# Path: riak/datatypes/types.py
# TYPES = {}


from .errors import ContextRequired
from . import TYPES

    def _raise_if_badtype(self, new_value):
        if not self._check_type(new_value):
            raise TypeError(self._type_error_msg)

    def __str__(self):
        return str(self.value)

    def _set_value(self, value):
        self._raise_if_badtype(value)
        self._value = self._coerce_value(value)

    def _default_value(self):
        """
        Returns what the initial value of an empty datatype should be.
        """
        raise NotImplementedError

    def _post_init(self):
        """
        Called at the end of :meth:`__init__` so that subclasses can tweak
        their own setup without overriding the constructor.
        """
        pass

    def _require_context(self):
        """
        Raises an exception if the context is not present
        """
        if not self._context:

# Path: riak/datatypes/errors.py
# class ContextRequired(RiakError):
#     """
#     This exception is raised when removals of map fields and set
#     entries are attempted and the datatype hasn't been initialized
#     with a context.
#     """
# 
#     _default_message = ("A context is required for remove operations, "
#                         "fetch the datatype first")
# 
#     def __init__(self, message=None):
#         super(ContextRequired, self).__init__(message or
#                                               self._default_message)
# 
# Path: riak/datatypes/types.py
# TYPES = {}


# Path: riak/datatypes/datatype.py
from .errors import ContextRequired
from . import TYPES


    def _raise_if_badtype(self, new_value):
        if not self._check_type(new_value):
            raise TypeError(self._type_error_msg)

    def __str__(self):
        return str(self.value)

    def _set_value(self, value):
        self._raise_if_badtype(value)
        self._value = self._coerce_value(value)

    def _default_value(self):
        """
        Returns what the initial value of an empty datatype should be.
        """
        raise NotImplementedError

    def _post_init(self):
        """
        Called at the end of :meth:`__init__` so that subclasses can tweak
        their own setup without overriding the constructor.
        """
        pass

    def _require_context(self):
        """
        Raises an exception if the context is not present
        """
        if not self._context:

            raise ContextRequired()