# 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
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.





class Scoped (Construct, models.Model):

    """Indicates that a statement (Topic Maps construct) has a
    scope. `Association`s, `Occurrence`s, `Name`s, and `Variant`s are
    scoped."""

    scope = models.ManyToManyField('Topic', related_name='scoped_%(class)ss')

    class Meta:
        abstract = True
        app_label = 'tmapi'

    def add_theme (self, theme):
        """Adds a topic to the scope.

        :param theme: the topic which should be added to the scope
        :type theme: `Topic`

        """
        if theme 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/scoped.py
from django.db import models
from tmapi.exceptions import ModelConstraintException
from construct import Construct

# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.





class Scoped (Construct, models.Model):

    """Indicates that a statement (Topic Maps construct) has a
    scope. `Association`s, `Occurrence`s, `Name`s, and `Variant`s are
    scoped."""

    scope = models.ManyToManyField('Topic', related_name='scoped_%(class)ss')

    class Meta:
        abstract = True
        app_label = 'tmapi'

    def add_theme (self, theme):
        """Adds a topic to the scope.

        :param theme: the topic which should be added to the scope
        :type theme: `Topic`

        """
        if theme is None:

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