twisted / twisted/twisted

URLPath should have an inverse to child() and here() isn't really here()

Open
#6,673 8 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

core enhancement new priority-normal url
Dominant language
Python
Stars
6k
Forks
1.2k
Avg merge
2d 10h
Merged PRs (30d)
10

Description

magmatt's avatar magmatt reported
Trac ID trac#6673
Type enhancement
Created 2013-08-07 17:20:59Z
Branch https://github.com/twisted/twisted/tree/url-up-here-6673

URLPath.parent is not the inverse of URLPath.child, which is unexpected:

>>> from twisted.python.urlpath import URLPath
>>> u = URLPath.fromString('http://example.com/foo/bar/baz')
>>> print u
http://example.com/foo/bar/baz
>>> print u.child('hey').parent()
http://example.com/foo/bar/

And I would expect URLPath.here() to be the way to get a URL without query parameters, but it's not:

>>> from twisted.python.urlpath import URLPath
>>> u = URLPath.fromString('http://example.com/foo/bar/baz?foo=1')
>>> print u
http://example.com/foo/bar/baz?foo=1
>>> print u.here()
http://example.com/foo/bar/

I propose adding two new methods that let you:

  1. Perform the inverse of .child('foo')
  2. Access the current url without query parameters.

(I apologize, but I just read in the docs that I should submit the ticket before writing a patch -- sorry)

Attachments:

  • urlpath.patch (2334 bytes) - added by magmatt on 2013-08-07 17:21:08Z -
  • 6673.2.patch (10622 bytes) - added by magmatt on 2013-09-19 16:14:00Z -
Searchable metadata
trac-id__6673 6673
type__enhancement enhancement
reporter__magmatt magmatt
priority__normal normal
milestone__ 
branch__branches_url_up_here_6673 branches/url-up-here-6673
branch_author__jonathanj jonathanj
status__new new
resolution__None None
component__core core
keywords__url url
time__1375896059000000 1375896059000000
changetime__1383471045000000 1383471045000000
version__None None
owner__ 

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in twisted.python.urlpath.URLPath and review the examples showing the behavior of parent(), child(), and here(). Check the existing url-up-here-6673 branch and attached patches, then verify that the requested inverse operation and query-free current URL behavior are covered.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
networking
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
32/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.