Skip to content

Commit

Permalink
Merge pull request #15 from danpoland/improve-expandables
Browse files Browse the repository at this point in the history
support comma separated lists in expandables query string params
  • Loading branch information
danpoland authored Feb 1, 2018
2 parents 0864446 + 73fbdb9 commit fa54df4
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion pyramid_restful/expandables.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,19 @@ def get_query(self):
"""
If your query is more complicated than what is supported below, override this method.
Don't forget to call super though.
The value of schema_class.QUERY_KEY supports comma separated lists.
"""

query = super(ExpandableViewMixin, self).get_query()
expandable_fields = getattr(self, 'expandable_fields', [])
query_key = self.schema_class.QUERY_KEY

if expandable_fields:
requested_expands = list(val for key, val in self.request.params.items() if key == query_key)
requested_expands = []

for key, val in self.request.params.items():
if key == query_key:
requested_expands += val.split(',')

if requested_expands:
available_expands = self.expandable_fields.keys()
Expand Down

0 comments on commit fa54df4

Please sign in to comment.