# Path: tmapi/exceptions.py
# class TopicMapExistsException (TMAPIException):
# 
#     """Exception thrown when an attempt is made to create a new
#     `TopicMap` under a storage address (an IRI) that is already
#     assigned to another `TopicMap` in the same `TopicMapSystem`."""
# 
#     pass
# 
# class FeatureNotRecognizedException (FactoryConfigurationException):
# 
#     """Exception raised when the TopicMapSystemFactory does not
#     recognize the name of a feature that the application is trying to
#     enable or disable."""
# 
#     pass


from django.db import models
from tmapi.exceptions import TopicMapExistsException, \
    FeatureNotRecognizedException
from locator import Locator
from tmapi_feature import TMAPIFeature
from topic_map import TopicMap
    """A generic interface to this TMAPI system."""

    class Meta:
        app_label = 'tmapi'

    def create_locator (self, reference):
        """Returns a `Locator` instance representing the specified IRI
        `reference`.

        The specified IRI `reference` is assumed to be absolute.

        :param reference: a string which uses the IRI notation
        :type reference: String
        :rtype: `Locator`

        """
        return Locator(reference)
    
    def create_topic_map (self, iri, proxy=TopicMap):
        """Creates a new `TopicMap` and stores it within the system
        under the specified `iri`.

        :param iri: the address which should be used to store the `TopicMap`
        :type iri: `Locator` or String
        :rtype: `TopicMap`

        """
        if not isinstance(iri, Locator):
            iri = self.create_locator(iri)
        if self.get_topic_map(iri) is not None:

# Path: tmapi/exceptions.py
# class TopicMapExistsException (TMAPIException):
# 
#     """Exception thrown when an attempt is made to create a new
#     `TopicMap` under a storage address (an IRI) that is already
#     assigned to another `TopicMap` in the same `TopicMapSystem`."""
# 
#     pass
# 
# class FeatureNotRecognizedException (FactoryConfigurationException):
# 
#     """Exception raised when the TopicMapSystemFactory does not
#     recognize the name of a feature that the application is trying to
#     enable or disable."""
# 
#     pass


# Path: tmapi/models/topic_map_system.py
from django.db import models
from tmapi.exceptions import TopicMapExistsException, \
    FeatureNotRecognizedException
from locator import Locator
from tmapi_feature import TMAPIFeature
from topic_map import TopicMap

    """A generic interface to this TMAPI system."""

    class Meta:
        app_label = 'tmapi'

    def create_locator (self, reference):
        """Returns a `Locator` instance representing the specified IRI
        `reference`.

        The specified IRI `reference` is assumed to be absolute.

        :param reference: a string which uses the IRI notation
        :type reference: String
        :rtype: `Locator`

        """
        return Locator(reference)
    
    def create_topic_map (self, iri, proxy=TopicMap):
        """Creates a new `TopicMap` and stores it within the system
        under the specified `iri`.

        :param iri: the address which should be used to store the `TopicMap`
        :type iri: `Locator` or String
        :rtype: `TopicMap`

        """
        if not isinstance(iri, Locator):
            iri = self.create_locator(iri)
        if self.get_topic_map(iri) is not None:

            raise TopicMapExistsException()