Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes | Static Public Attributes
urllib.request.FTPHandler Class Reference
Inheritance diagram for urllib.request.FTPHandler:
Inheritance graph
[legend]
Collaboration diagram for urllib.request.FTPHandler:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def ftp_open
def connect_ftp
def add_parent
def close
def __lt__

Public Attributes

 parent

Static Public Attributes

int handler_order = 500

Detailed Description

Definition at line 1310 of file request.py.


Member Function Documentation

def urllib.request.BaseHandler.__lt__ (   self,
  other 
) [inherited]

Definition at line 467 of file request.py.

00467 
00468     def __lt__(self, other):
00469         if not hasattr(other, "handler_order"):
00470             # Try to preserve the old behavior of having custom classes
00471             # inserted after default ones (works only for custom user
00472             # classes which are not aware of handler_order).
00473             return True
00474         return self.handler_order < other.handler_order
00475 

def urllib.request.BaseHandler.add_parent (   self,
  parent 
) [inherited]

Definition at line 460 of file request.py.

00460 
00461     def add_parent(self, parent):
00462         self.parent = parent

def urllib.request.BaseHandler.close (   self) [inherited]

Definition at line 463 of file request.py.

00463 
00464     def close(self):
00465         # Only exists for backwards compatibility
00466         pass

Here is the caller graph for this function:

def urllib.request.FTPHandler.connect_ftp (   self,
  user,
  passwd,
  host,
  port,
  dirs,
  timeout 
)

Reimplemented in urllib.request.CacheFTPHandler.

Definition at line 1364 of file request.py.

01364 
01365     def connect_ftp(self, user, passwd, host, port, dirs, timeout):
01366         return ftpwrapper(user, passwd, host, port, dirs, timeout,
01367                           persistent=False)

Here is the caller graph for this function:

def urllib.request.FTPHandler.ftp_open (   self,
  req 
)

Definition at line 1311 of file request.py.

01311 
01312     def ftp_open(self, req):
01313         import ftplib
01314         import mimetypes
01315         host = req.host
01316         if not host:
01317             raise URLError('ftp error: no host given')
01318         host, port = splitport(host)
01319         if port is None:
01320             port = ftplib.FTP_PORT
01321         else:
01322             port = int(port)
01323 
01324         # username/password handling
01325         user, host = splituser(host)
01326         if user:
01327             user, passwd = splitpasswd(user)
01328         else:
01329             passwd = None
01330         host = unquote(host)
01331         user = user or ''
01332         passwd = passwd or ''
01333 
01334         try:
01335             host = socket.gethostbyname(host)
01336         except socket.error as msg:
01337             raise URLError(msg)
01338         path, attrs = splitattr(req.selector)
01339         dirs = path.split('/')
01340         dirs = list(map(unquote, dirs))
01341         dirs, file = dirs[:-1], dirs[-1]
01342         if dirs and not dirs[0]:
01343             dirs = dirs[1:]
01344         try:
01345             fw = self.connect_ftp(user, passwd, host, port, dirs, req.timeout)
01346             type = file and 'I' or 'D'
01347             for attr in attrs:
01348                 attr, value = splitvalue(attr)
01349                 if attr.lower() == 'type' and \
01350                    value in ('a', 'A', 'i', 'I', 'd', 'D'):
01351                     type = value.upper()
01352             fp, retrlen = fw.retrfile(file, type)
01353             headers = ""
01354             mtype = mimetypes.guess_type(req.full_url)[0]
01355             if mtype:
01356                 headers += "Content-type: %s\n" % mtype
01357             if retrlen is not None and retrlen >= 0:
01358                 headers += "Content-length: %d\n" % retrlen
01359             headers = email.message_from_string(headers)
01360             return addinfourl(fp, headers, req.full_url)
01361         except ftplib.all_errors as msg:
01362             exc = URLError('ftp error: %s' % msg)
01363             raise exc.with_traceback(sys.exc_info()[2])

Here is the call graph for this function:


Member Data Documentation

int urllib.request.BaseHandler.handler_order = 500 [static, inherited]

Definition at line 461 of file request.py.


The documentation for this class was generated from the following file: