Issue #29 resolved

Fields should be relative to defining handler

Seph Soliman
created an issue

If primary handler, tried to a model (i.e. Photo) defines a field which is actually a method on that handler, then a secondary handler will attempt to call the method locally on itself when it exports those types (i.e. Photos).

The method called should be the one of the original handler, not the using handler. Let me try with an example:

{{{

!python

class PhotoHandler(AnonymousBaseHandler): model = Photo fields = ('id', 'title', 'original', 'thumbnails',)

def thumbnails(self, photo):
    return {
        'normal': photo.original.thumbnail.relative_url,
        # (...)

def read(self, request, photo_id):
    # in here, return Photo() will return the thumbnails

class FrontpageHandler(AnonymousBaseHandler): def read(self, request): section_photo = Photo.objects.filter().order_by('-id') or [None] return section_photo # in here, return section_photo will return the right fields, # but leave out the "resource method", thumbnails() # sine it isn't defined in the frontpagehandler. }}}

Perhaps a workaround is possible...

Comments (1)

  1. Log in to comment