urllib2_file
index
/Users/buggy/Documents/code/OmixedPythonLibrary/urllib2_file.py

enable to upload files using multipart/form-data
 
idea from:
upload files in python:
 http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/146306
 
timeoutsocket.py: overriding Python socket API:
 http://www.timo-tasi.org/python/timeoutsocket.py
 http://mail.python.org/pipermail/python-announce-list/2001-December/001095.html
 
import urllib2_files
import urllib2
u = urllib2.urlopen('http://site.com/path' [, data])
 
data can be a mapping object or a sequence of two-elements tuples
(like in original urllib2.urlopen())
varname still need to be a string and
value can be string of a file object
eg:
  ((varname, value),
   (varname2, value),
  )
  or
  { name:  value,
    name2: value2
  }

 
Modules
       
httplib
mimetools
mimetypes
os
socket
stat
sys
urllib
urllib2

 
Classes
       
urllib2.BaseHandler
newHTTPHandler
newHTTPSHandler

 
class newHTTPHandler(urllib2.BaseHandler)
    # mainly a copy of HTTPHandler from urllib2
 
  Methods defined here:
do_open(self, http_class, req)
http_open(self, req)

Methods inherited from urllib2.BaseHandler:
__lt__(self, other)
add_parent(self, parent)
close(self)

Data and other attributes inherited from urllib2.BaseHandler:
handler_order = 500

 
class newHTTPSHandler(newHTTPHandler)
    
Method resolution order:
newHTTPSHandler
newHTTPHandler
urllib2.BaseHandler

Methods defined here:
https_open(self, req)

Methods inherited from newHTTPHandler:
do_open(self, http_class, req)
http_open(self, req)

Methods inherited from urllib2.BaseHandler:
__lt__(self, other)
add_parent(self, parent)
close(self)

Data and other attributes inherited from urllib2.BaseHandler:
handler_order = 500

 
Functions
       
get_content_type(filename)
send_data(v_vars, v_files, boundary, sock=None)
# if sock is None, juste return the estimate size

 
Data
        CHUNK_SIZE = 65536