1

No matter what I tried, I cannot resolve the recursion with request handlers for my simple OneToMany relationship, let's say Father 1 : N Sons

FatherHandler shall return sons_set (list of sons) in it's resultset. SonHandler shall return the father object in resultset.

As the fields, exclude, settings seem to be statically bound to a handler (and the model behind), it seems not to be possible to dynamically change the fields to be returned and I always end up with a recursion. (I did e.g. try to exclude sons_set from fields list when called from SonHandler, but the initial FatherHandler settings still seems to be in effect)

class FatherHandler(GenericHandler):
    model = Father
    exclude = () # to also show 'id' field
    fields = ('id', 'name', ('son_set', ('id', 'name')))
    allowed_methods = ('GET', 'POST', 'PUT')

class SonHandler(GenericHandler):
    model = Son
    exclude = () # to also show 'id' field
    fields = ('id', 'name', ('father', ('id', 'name')))
    allowed_methods = ('GET', 'POST', 'PUT', 'DELETE')

    def read(self, request, key=None):
        FatherHandler.exclude = ('son_set')
        # does not work ...
Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Knackling
  • 21
  • 1
  • I found a Solution by applying [this](https://bitbucket.org/easel/django-piston/commits/f92035638c9f/) Patch to Piston emittier.py. Still Wondering why Dynamic changing of Fields Does Not work. – Knackling Apr 17 '13 at 17:47

0 Answers0