1

I am using Django 1.5 with Piston. Whenever I try to curl the following url:

http://127.0.0.1:8000/search/?limit=20&uri=

I get the following error:

["NotFound"]

The url pattern:

search_resource = Resource(handler=SearchHandler)

urlpatterns = patterns('',
    url(r'^', annotation_resource),
    url(r'^search/$', search_resource),

)

and the handler for the request:

class SearchHandler(AnonymousBaseHandler):
    allowed_methods = ('GET',)
    def read(self, request, id=None):
        non_query_args = ['offset', 'limit', 'all_fields']
        offset = int(request.GET.get('offset', 0))
        limit = int(request.GET.get('limit', 20))
        query=dict([(k,v) for k,v in request.GET.items() if not k in non_query_args])
        notes = Annotations.find(query).limit(limit).skip(offset) #.sort([(, pymongo.DESCENDING if orderDesc else pymongo.ASCENDING)])

        return {'results': [dict([(k,v) if k!='_id' else ('id',v) for k,v in item.items()]) for item in notes],
                'total': notes.count()}

I couldn't figure the issue due to the lack of verbosity in the error. /Thanks

tank
  • 319
  • 6
  • 15

1 Answers1

0

I fixed the issue. The problem was here:

def read(self, request, id=None):

Removed id=None and reordered the url patterns, so that it goes to the right handler.

urlpatterns = patterns('',
    url(r'^search/$', search_resource),
    url(r'^(?P<id>.*)$', annotation_resource),
}
tank
  • 319
  • 6
  • 15