Skip to content

Instantly share code, notes, and snippets.

@horiajurcut
Last active August 29, 2015 14:03
Show Gist options
  • Save horiajurcut/8390d82b7dbdc9979da1 to your computer and use it in GitHub Desktop.
Save horiajurcut/8390d82b7dbdc9979da1 to your computer and use it in GitHub Desktop.
for endpoint in ModelView.__subclasses__():
def relationships(self, id):
print id
for key in endpoint.model.__dict__:
if key.endswith('_id'):
setattr(endpoint, 'related_%s' % (key), types.MethodType(
route(
rule='/<id>/related_%s' % (key),
endpoint='related_%s' % (key),
methods=['GET']
)(relationships), None, endpoint
))
endpoint.register(app, route_prefix='/v1/')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment