Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support removal of multiple value same key URLs #29

Closed
jstarcher opened this issue Jan 7, 2014 · 3 comments
Closed

Support removal of multiple value same key URLs #29

jstarcher opened this issue Jan 7, 2014 · 3 comments

Comments

@jstarcher
Copy link

Is it possible to use the .remove() method with multiple value keys?

# Actual
>>> furl('/foo/?gender=M&gender=F&location=CA').remove({'gender': 'M'}).url
'/foo/?location=CA'

# Expected
>>> furl('/foo/?gender=M&gender=F&location=CA').remove({'gender': 'M'}).url
'/foo/?gender=F&location=CA'

# Workaround
>>> f = furl('/foo/?gender=M&gender=F&location=CA')
>>> f.args.popvalue('gender', 'M')
>>> print f.url
'/foo/?gender=F&location=CA'
@gruns
Copy link
Owner

gruns commented Jan 8, 2014

This would be useful, albeit infrequently used.

Removing multiple keys will also be supported when provided a dictionary with
list values or any 'dictionary-like' iterable.

>>> furl('/foo/?gender=M&gender=F&gender=robot')
      .remove([('gender','M'),('gender','F')]).url
'/foo/?gender=robot'

>>> furl('/foo/?gender=M&gender=F&gender=robot')
      .remove({'gender': 'M'}).url
'/foo/?gender=M&gender=robot'

I'll add such functionality shortly.

@gruns
Copy link
Owner

gruns commented Jan 22, 2014

furl v0.3.7's Query.remove() supports the removal of multiple values from the
same key through a list of items, a dictionary, or a multivalue dictionary.

>>> furl('/foo/?gender=M&gender=F&location=CA').remove({'gender': 'M'}).url
'/foo/?gender=F&location=CA'

>>> furl('/foo/?gender=M&gender=F&location=CA').remove([('gender', 'M')]).url
'/foo/?gender=F&location=CA'

>>> from orderedmultidict import omdict
>>> omd = omdict([('gender', 'M'), ('location', 'CA')])
>>> furl('/foo/?gender=M&gender=F&location=CA').remove(omd).url
'/foo/?gender=F'

Upgrade to furl v0.3.7 with

pip install furl --upgrade

Thank you for bringing this issue to my attention jstarcher.

@gruns gruns closed this as completed Jan 22, 2014
@jstarcher
Copy link
Author

Great work, thanks @gruns!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants