i've started to build a backend for a sproutcore app with piston, but
it is really annoying that piston follows foreign keys. for mildly
complex data strcutures this results in WAY too much data being
returned. also sproutcore will handle all relations internally and
expects the backend to return resource ids instead of the already
expanded resource
i haven't found a way to disable this feature, except for some monkey
patching. maybe a configuration option should be added?
Thanks,
Bene
What you *can* do, is override the fields, with what's called
"resource methods." This allows you to override what comes out of that
resource.
For example:
class FooHandler(BaseHandler):
model = Foo
fields = ('id', 'something_fk', ...)
@classmethod
def something_fk(cls, sfk):
return sfk.id
Say 'something_fk' is a foreign key on Foo, now it will pipe that
object through to the 'something_fk' method and return what comes out
of there instead.
HTH,
Jesper