Last active
August 29, 2015 14:03
-
-
Save horiajurcut/8390d82b7dbdc9979da1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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