Issue #193 open

Method signature does not match. Signature should be: expression

Anonymous created an issue

I followed the instructions to get piston working. But I can't get it to work properly.

folder: api

urls.py:

from django.conf.urls.defaults import * from piston.resource import Resource from project.api.handlers import PlaceHandler

places_handler = Resource(PlaceHandler)

urlpatterns = patterns('', url(r'^place/(?P<place_id>[^/]+)/', places_handler, { 'emitter_format': 'json' }), url(r'^places/', places_handler, { 'emitter_format': 'json' }), )

and handlers.py:

from piston.handler import BaseHandler from website.models import Place

class PlaceHandler(BaseHandler): model = Place

def read(self, request):
    base = Place.objects
    return base.all()

Then in browser: http://grabit.magile.nl/api/places/

Complete error message:

Piston/0.2.2 (Django 1.3) crash report:

Method signature does not match.

Signature should be: expression

Exception was: read() takes exactly 3 arguments (2 given)

Comments (2)

  1. Anonymous

    Hello Jesper,

    I got the same error after that change:

    class PlaceHandler(BaseHandler): model = Place

    def read(self, request, place_id=None): """ Returns a single post if `blogpost_id` is given, otherwise a subset.

    """ base = Place.objects return base.all() if place_id: return base.get(pk=place_id) else: return base.all()

  2. Log in to comment