[Python-checkins] python/dist/src/Doc/lib liburllib.tex,1.43,1.44

fdrake@users.sourceforge.net fdrake@users.sourceforge.net
Tue, 22 Oct 2002 14:58:11 -0700


Update of /cvsroot/python/python/dist/src/Doc/lib
In directory usw-pr-cvs1:/tmp/cvs-serv8580

Modified Files:
	liburllib.tex 
Log Message:
Moved description of _urlopener adjacent to the related functions.
Added missing import to example code.

Added documentation for pathname2url(), url2pathname().
Closes SF bug #623196.


Index: liburllib.tex
===================================================================
RCS file: /cvsroot/python/python/dist/src/Doc/lib/liburllib.tex,v
retrieving revision 1.43
retrieving revision 1.44
diff -C2 -d -r1.43 -r1.44
*** liburllib.tex	4 Apr 2002 20:58:02 -0000	1.43
--- liburllib.tex	22 Oct 2002 21:58:06 -0000	1.44
***************
*** 141,144 ****
--- 141,168 ----
  \end{funcdesc}
  
+ \begin{datadesc}{_urlopener}
+ The public functions \function{urlopen()} and
+ \function{urlretrieve()} create an instance of the
+ \class{FancyURLopener} class and use it to perform their requested
+ actions.  To override this functionality, programmers can create a
+ subclass of \class{URLopener} or \class{FancyURLopener}, then assign
+ that an instance of that class to the
+ \code{urllib._urlopener} variable before calling the desired function.
+ For example, applications may want to specify a different
+ \mailheader{User-Agent} header than \class{URLopener} defines.  This
+ can be accomplished with the following code:
+ 
+ \begin{verbatim}
+ import urllib
+ 
+ class AppURLopener(urllib.FancyURLopener):
+     def __init__(self, *args):
+         self.version = "App/1.7"
+         urllib.FancyURLopener.__init__(self, *args)
+ 
+ urllib._urlopener = AppURLopener()
+ \end{verbatim}
+ \end{datadesc}
+ 
  \begin{funcdesc}{urlcleanup}{}
  Clear the cache that may have been built up by previous calls to
***************
*** 189,211 ****
  \end{funcdesc}
  
! The public functions \function{urlopen()} and
! \function{urlretrieve()} create an instance of the
! \class{FancyURLopener} class and use it to perform their requested
! actions.  To override this functionality, programmers can create a
! subclass of \class{URLopener} or \class{FancyURLopener}, then assign
! that an instance of that class to the
! \code{urllib._urlopener} variable before calling the desired function.
! For example, applications may want to specify a different
! \mailheader{User-Agent} header than \class{URLopener} defines.  This
! can be accomplished with the following code:
! 
! \begin{verbatim}
! class AppURLopener(urllib.FancyURLopener):
!     def __init__(self, *args):
!         self.version = "App/1.7"
!         urllib.FancyURLopener.__init__(self, *args)
  
! urllib._urlopener = AppURLopener()
! \end{verbatim}
  
  \begin{classdesc}{URLopener}{\optional{proxies\optional{, **x509}}}
--- 213,228 ----
  \end{funcdesc}
  
! \begin{funcdesc}{pathname2url}{path}
! Convert the pathname \var{path} from the local syntax for a path to
! the form used in the path component of a URL.  This does not produce a
! complete URL.  The return value will already be quoted using the
! \function{quote()} function.
! \end{funcdesc}
  
! \begin{funcdesc}{url2pathname}{path}
! Convert the path component \var{path} from an encoded URL to the local
! syntax for a path.  This does not accept a complete URL.  This
! function uses \function{unquote()} to decode \var{path}.
! \end{funcdesc}
  
  \begin{classdesc}{URLopener}{\optional{proxies\optional{, **x509}}}