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 ...