# Path: riv/exceptions.py
# class ConfigurationError(RestfulAPIError):
#     pass


from django.conf.urls import patterns
from riv.exceptions import ConfigurationError

class Api(object):
    """
    The Api class is used to bind together different resources
    that form a full API. This is necessary to perform url
    resolution for related objects.
    It also allows to register the same resource with multiple
    different apis.
    """
    def __init__(self, name):
        self.name = name
        self._resource_list = {}

    def register(self, resource):
        name = getattr(resource._meta, 'name')
        if not name:
            raise ConfigurationError("Resource %s does not have a name assigned." % (resource,))
        if resource._meta.model:
            if self._resource_list.has_key(resource._meta.model):
                self._resource_list[resource._meta.model][name] = resource
            else:
                self._resource_list[resource._meta.model] = {name: resource}
        else:
            self._resource_list[name] = {name: resource}
        resource._meta.api_name = self.name

    def unregister(self, resource):
        name = getattr(resource._meta, 'name')
        if not name:

# Path: riv/exceptions.py
# class ConfigurationError(RestfulAPIError):
#     pass


# Path: riv/api.py
from django.conf.urls import patterns
from riv.exceptions import ConfigurationError


class Api(object):
    """
    The Api class is used to bind together different resources
    that form a full API. This is necessary to perform url
    resolution for related objects.
    It also allows to register the same resource with multiple
    different apis.
    """
    def __init__(self, name):
        self.name = name
        self._resource_list = {}

    def register(self, resource):
        name = getattr(resource._meta, 'name')
        if not name:
            raise ConfigurationError("Resource %s does not have a name assigned." % (resource,))
        if resource._meta.model:
            if self._resource_list.has_key(resource._meta.model):
                self._resource_list[resource._meta.model][name] = resource
            else:
                self._resource_list[resource._meta.model] = {name: resource}
        else:
            self._resource_list[name] = {name: resource}
        resource._meta.api_name = self.name

    def unregister(self, resource):
        name = getattr(resource._meta, 'name')
        if not name:

            raise ConfigurationError("Resource %s does not have a name assigned." % (resource,))