# Path: riv/api.py
# 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,))
#         if name in self._resource_list:
#             del self._resource_list[name]
# 
#     def _get_urls(self):
#         urlpatterns = patterns('')
#         for model_or_name,resources in self._resource_list.items():
#             multiple_reverse_counter = 0
#             if len(resources) > 1:
#                 for name,resource in resources.items():
#                     if resource._meta.reverse:
#                         if multiple_reverse_counter > 0:
#                             raise ConfigurationError("Multiple resources in api '%s' with 'reverse=True' for model %s found" % (self.name, resource._meta.model))
#                         else:
#                             multiple_reverse_counter += 1
#                     urlpatterns += resource.urls
#             else:
#                 urlpatterns += resources.values()[0].urls_with_reverse
#         return urlpatterns
# 
#     urls = property(_get_urls)


from django.conf.urls import patterns, include, url
from polls.resources import StandaloneReadOnlyChoiceResource, ReadOnlyPollResource, ReadWritePollResource, \
        StandaloneReadOnlyPollResource, StandaloneReadWritePollResource, StandaloneReadWritePollResource2, \
        StandaloneExcludeGetOnly, StandaloneExcludePostOnly, StandaloneExcludePutOnly, StandaloneTagResource, \
        VoteResource, PutOnlyPollResource, PostOnlyPollResource, DeleteOnlyPollResource, \
        StandalonePutOnlyPollResource, StandalonePostOnlyPollResource, StandaloneDeleteOnlyPollResource, \
        BatchPostPollResource, BatchDeletePollResource, ReadWriteRenderPollResource, ResultResource, \
        NoFallbackPollResource, RelatedAsIdsPollResource, FieldsPollResource, ExcludePollResource, \
        InlinePollResource, ExtraPollResource, MapPollResource, StandaloneBatchPostPollResource
from riv.api import Api


# Uncomment the next two lines to enable the admin:
# from django.contrib import admin
# admin.autodiscover()

api = Api(name='rest1')

api.register(RelatedAsIdsPollResource(name='raipr'))
api.register(NoFallbackPollResource(name='nfpr'))
api.register(ReadOnlyPollResource(name='ropr'))
api.register(PutOnlyPollResource(name='puopr'))
api.register(PostOnlyPollResource(name='poopr'))
api.register(DeleteOnlyPollResource(name='dopr'))
api.register(ReadWritePollResource(name='rwpr'))
api.register(ReadWriteRenderPollResource(name='rwrpr'))
api.register(BatchDeletePollResource(name='bdpr'))
api.register(BatchPostPollResource(name='bppr'))
api.register(FieldsPollResource(name='fpr'))
api.register(ExcludePollResource(name='excpr'))
api.register(InlinePollResource(name='ipr'))
api.register(ExtraPollResource(name='extpr'))
api.register(MapPollResource(name='mpr'))
api.register(StandaloneReadOnlyPollResource(name='srpr'))
api.register(StandalonePutOnlyPollResource(name='spuopr'))
api.register(StandalonePostOnlyPollResource(name='spoopr'))

# Path: riv/api.py
# 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,))
#         if name in self._resource_list:
#             del self._resource_list[name]
# 
#     def _get_urls(self):
#         urlpatterns = patterns('')
#         for model_or_name,resources in self._resource_list.items():
#             multiple_reverse_counter = 0
#             if len(resources) > 1:
#                 for name,resource in resources.items():
#                     if resource._meta.reverse:
#                         if multiple_reverse_counter > 0:
#                             raise ConfigurationError("Multiple resources in api '%s' with 'reverse=True' for model %s found" % (self.name, resource._meta.model))
#                         else:
#                             multiple_reverse_counter += 1
#                     urlpatterns += resource.urls
#             else:
#                 urlpatterns += resources.values()[0].urls_with_reverse
#         return urlpatterns
# 
#     urls = property(_get_urls)


# Path: tests/testapp/urls.py
from django.conf.urls import patterns, include, url
from polls.resources import StandaloneReadOnlyChoiceResource, ReadOnlyPollResource, ReadWritePollResource, \
        StandaloneReadOnlyPollResource, StandaloneReadWritePollResource, StandaloneReadWritePollResource2, \
        StandaloneExcludeGetOnly, StandaloneExcludePostOnly, StandaloneExcludePutOnly, StandaloneTagResource, \
        VoteResource, PutOnlyPollResource, PostOnlyPollResource, DeleteOnlyPollResource, \
        StandalonePutOnlyPollResource, StandalonePostOnlyPollResource, StandaloneDeleteOnlyPollResource, \
        BatchPostPollResource, BatchDeletePollResource, ReadWriteRenderPollResource, ResultResource, \
        NoFallbackPollResource, RelatedAsIdsPollResource, FieldsPollResource, ExcludePollResource, \
        InlinePollResource, ExtraPollResource, MapPollResource, StandaloneBatchPostPollResource
from riv.api import Api



# Uncomment the next two lines to enable the admin:
# from django.contrib import admin
# admin.autodiscover()

api = Api(name='rest1')

api.register(RelatedAsIdsPollResource(name='raipr'))
api.register(NoFallbackPollResource(name='nfpr'))
api.register(ReadOnlyPollResource(name='ropr'))
api.register(PutOnlyPollResource(name='puopr'))
api.register(PostOnlyPollResource(name='poopr'))
api.register(DeleteOnlyPollResource(name='dopr'))
api.register(ReadWritePollResource(name='rwpr'))
api.register(ReadWriteRenderPollResource(name='rwrpr'))
api.register(BatchDeletePollResource(name='bdpr'))
api.register(BatchPostPollResource(name='bppr'))
api.register(FieldsPollResource(name='fpr'))
api.register(ExcludePollResource(name='excpr'))
api.register(InlinePollResource(name='ipr'))
api.register(ExtraPollResource(name='extpr'))
api.register(MapPollResource(name='mpr'))
api.register(StandaloneReadOnlyPollResource(name='srpr'))
api.register(StandalonePutOnlyPollResource(name='spuopr'))
api.register(StandalonePostOnlyPollResource(name='spoopr'))

api.register(StandaloneBatchPostPollResource(name='sbppr'))