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

attributes for urlsplit, urlparse result #37332

Closed
freddrake opened this issue Oct 16, 2002 · 8 comments
Closed

attributes for urlsplit, urlparse result #37332

freddrake opened this issue Oct 16, 2002 · 8 comments
Assignees
Labels
stdlib Python modules in the Lib dir

Comments

@freddrake
Copy link
Member

BPO 624325
Nosy @gvanrossum, @freddrake, @birkenfeld
Files
  • urlparse-attributes.patch: fifth version; mostly a different patch, with more tests
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = 'https://github.com/freddrake'
    closed_at = <Date 2006-04-01.22:15:46.000>
    created_at = <Date 2002-10-16.21:59:16.000>
    labels = ['library']
    title = 'attributes for urlsplit, urlparse result'
    updated_at = <Date 2006-04-01.22:15:46.000>
    user = 'https://github.com/freddrake'

    bugs.python.org fields:

    activity = <Date 2006-04-01.22:15:46.000>
    actor = 'fdrake'
    assignee = 'fdrake'
    closed = True
    closed_date = None
    closer = None
    components = ['Library (Lib)']
    creation = <Date 2002-10-16.21:59:16.000>
    creator = 'fdrake'
    dependencies = []
    files = ['4642']
    hgrepos = []
    issue_num = 624325
    keywords = ['patch']
    message_count = 8.0
    messages = ['41395', '41396', '41397', '41398', '41399', '41400', '41401', '41402']
    nosy_count = 3.0
    nosy_names = ['gvanrossum', 'fdrake', 'georg.brandl']
    pr_nums = []
    priority = 'normal'
    resolution = 'accepted'
    stage = None
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue624325'
    versions = ['Python 2.5']

    @freddrake
    Copy link
    Member Author

    This patch to Lib/urlparse.py makes the fields of the
    results accessible as named attributes from the result
    object. The result objects are still small since they
    derive from tuple and have no __dict__, though there's
    some additional cost in construction (a temporary tuple
    is created and passed to tuple.__new__).

    @freddrake freddrake self-assigned this Oct 16, 2002
    @freddrake freddrake added the stdlib Python modules in the Lib dir label Oct 16, 2002
    @freddrake freddrake self-assigned this Oct 16, 2002
    @freddrake
    Copy link
    Member Author

    Logged In: YES
    user_id=3066

    New version of the patch.

    This adds a "url" attribute to each type of result,
    providing the result of urlunsplit() / urlunparse() for the
    components of the result object.

    Tests and documentation have been updated.

    @freddrake
    Copy link
    Member Author

    Logged In: YES
    user_id=3066

    Based on comments from Guido, provide a geturl() method
    instead of the url property, since it actually does more
    work than just retrieving data.

    @gvanrossum
    Copy link
    Member

    Logged In: YES
    user_id=6380

    I'm fine with this, but we decided to use a different
    approach (for the same effect): make structseq usable from
    Python code. That's being discussed in bug 624827. Pending
    that, this one's on hold.

    @freddrake
    Copy link
    Member Author

    Logged In: YES
    user_id=3066

    I've attached a new version of the patch that simplifies the
    code for the new types.

    It doesn't look like I'll bet getting to magic structseq
    support anytime soon. I'm also no longer convinced that
    this needs to be held up for that. This should be
    considered for Python 2.5 on the basis of the feature; the
    implementation can be changed some someone get around to
    creation of structseq types from Python.

    @birkenfeld
    Copy link
    Member

    Logged In: YES
    user_id=1188172

    Here is a diff to the patch that corrects the
    \versionchanged commands and the use of the geturl() in the
    example:

    --- urlparse.patch      2005-04-02 18:38:06.979685348 +0200
    +++ urlparse-new.patch  2005-04-02 18:42:03.124933001 +0200
    @@ -168,7 +168,7 @@
      ('http', 'www.cwi.nl:80', '/%7Eguido/Python.html', '', '', '')
     +>>> o.scheme
     +'http'
    -+>>> o.url
    ++>>> o.geturl()
     +'http://www.cwi.nl:80/%7Eguido/Python.html'
      \end{verbatim}
    
    @@ -189,7 +189,7 @@
     +\var{urlstring}.
     +
     +\versionchanged[Support for attributes on the result
    object was
    -+                added]{2.3}
    ++                added]{2.5}
      \end{funcdesc}
    
      \begin{funcdesc}{urlunparse}{tuple}
    @@ -236,7 +236,7 @@
     +
      \versionadded{2.2}
     +\versionchanged[Support for attributes on the result
    object was
    -+                added]{2.3}
    ++                added]{2.5}
      \end{funcdesc}

    \begin{funcdesc}{urlunsplit}{tuple}

    @freddrake
    Copy link
    Member Author

    Logged In: YES
    user_id=3066

    Here's a new version of the patch. This takes birkenfeld's
    changes into account, adds more tests and documentation, and
    adds four more attributes to the result objects: username,
    password, hostname, and port. These provide access to
    parsed-out portions of the netloc component. These are
    computed on demand only.

    Much of this patch was written independently, but I've taken
    the previous patches into consideration to make sure I
    didn't miss anything already accounted for.

    I think this is good for 2.5 still, and will commit this
    weekend if there are no objections.

    @freddrake
    Copy link
    Member Author

    Logged In: YES
    user_id=3066

    Committed as trunk revision 43546.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 9, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    stdlib Python modules in the Lib dir
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants