Title: attributes for urlsplit, urlparse result
Type: Stage:
Components: Library (Lib) Versions: Python 2.5
Status: closed Resolution: accepted
Dependencies: Superseder:
Assigned To: fdrake Nosy List: fdrake, georg.brandl, gvanrossum
Priority: normal Keywords: patch

Created on 2002-10-16 21:59 by fdrake, last changed 2006-04-01 22:15 by fdrake. This issue is now closed.

File name Uploaded Description Edit
urlparse-attributes.patch fdrake, 2006-04-01 06:23 fifth version; mostly a different patch, with more tests
Messages (8)
msg41395 - (view) Author: Fred Drake (fdrake) (Python committer) Date: 2002-10-16 21:59
This patch to Lib/ 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__).
msg41396 - (view) Author: Fred Drake (fdrake) (Python committer) Date: 2002-10-17 17:09
Logged In: YES 

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.
msg41397 - (view) Author: Fred Drake (fdrake) (Python committer) Date: 2002-10-17 20:03
Logged In: YES 

Based on comments from Guido, provide a geturl() method
instead of the url property, since it actually does more
work than just retrieving data.
msg41398 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2002-11-14 17:37
Logged In: YES 

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.
msg41399 - (view) Author: Fred Drake (fdrake) (Python committer) Date: 2004-10-17 19:10
Logged In: YES 

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.
msg41400 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2005-04-02 16:44
Logged In: YES 

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

--- 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', '', '/%7Eguido/Python.html', '', '', '')
 +>>> o.scheme
-+>>> o.url
++>>> o.geturl()

@@ -189,7 +189,7 @@
 +\versionchanged[Support for attributes on the result
object was
-+                added]{2.3}
++                added]{2.5}

@@ -236,7 +236,7 @@
 +\versionchanged[Support for attributes on the result
object was
-+                added]{2.3}
++                added]{2.5}

msg41401 - (view) Author: Fred Drake (fdrake) (Python committer) Date: 2006-04-01 06:23
Logged In: YES 

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.
msg41402 - (view) Author: Fred Drake (fdrake) (Python committer) Date: 2006-04-01 22:15
Logged In: YES 

Committed as trunk revision 43546.
Date User Action Args
2002-10-16 21:59:16fdrakecreate