# Path: tmapi/exceptions.py
# class ModelConstraintException (TMAPIRuntimeException):
# 
#     """This exception is used to report Topic Maps - Data Model
#     constraint violations."""
# 
#     def __init__ (self, reporter, message):
#         """Creates a new ModelConstraintException with the specified
#         message.
# 
#         :param reporter: the construct which has thrown this exception
#         :type reporter: `Construct`
#         :param message: the detail message
#         :type message: string
# 
#         """
#         self._reporter = reporter
#         self._message = message
#     
#     def get_reporter (self):
#         """Return the `Construct` which has thrown the exception.
# 
#         :rtype: `Construct`
# 
#         """
#         return self._reporter


from django.db import models
from tmapi.exceptions import ModelConstraintException
from construct import Construct
    `Role`s, `Occurrence`s, and `Name`s are typed."""

    type = models.ForeignKey('Topic', related_name='typed_%(class)ss')
    
    class Meta:
        abstract = True
        app_label = 'tmapi'
    
    def get_type (self, proxy=None):
        """Returns the type of this construct.

        :param proxy: Django proxy model
        :type proxy: class
        :rtype: the `Topic` that represents the type

        """
        construct_type = self.type
        if proxy is not None:
            construct_type = proxy.objects.get(pk=construct_type.pk)
        return construct_type

    def set_type (self, construct_type):
        """Sets the type of this construct. Any previous type is overridden.

        :param construct_type: the `Topic` that should define the
          nature of this construct
        :type construct_type: `Topic`

        """
        if construct_type is None:

# Path: tmapi/exceptions.py
# class ModelConstraintException (TMAPIRuntimeException):
# 
#     """This exception is used to report Topic Maps - Data Model
#     constraint violations."""
# 
#     def __init__ (self, reporter, message):
#         """Creates a new ModelConstraintException with the specified
#         message.
# 
#         :param reporter: the construct which has thrown this exception
#         :type reporter: `Construct`
#         :param message: the detail message
#         :type message: string
# 
#         """
#         self._reporter = reporter
#         self._message = message
#     
#     def get_reporter (self):
#         """Return the `Construct` which has thrown the exception.
# 
#         :rtype: `Construct`
# 
#         """
#         return self._reporter


# Path: tmapi/models/typed.py
from django.db import models
from tmapi.exceptions import ModelConstraintException
from construct import Construct

    `Role`s, `Occurrence`s, and `Name`s are typed."""

    type = models.ForeignKey('Topic', related_name='typed_%(class)ss')
    
    class Meta:
        abstract = True
        app_label = 'tmapi'
    
    def get_type (self, proxy=None):
        """Returns the type of this construct.

        :param proxy: Django proxy model
        :type proxy: class
        :rtype: the `Topic` that represents the type

        """
        construct_type = self.type
        if proxy is not None:
            construct_type = proxy.objects.get(pk=construct_type.pk)
        return construct_type

    def set_type (self, construct_type):
        """Sets the type of this construct. Any previous type is overridden.

        :param construct_type: the `Topic` that should define the
          nature of this construct
        :type construct_type: `Topic`

        """
        if construct_type is None:

            raise ModelConstraintException(self, 'The type may not be None')