code: def __encodeMultipart(self, fields, files):
          
          boundary = mimetools.choose_boundary()
          crlf = '\r\n'
  
          l = []
          for k, v in fields:
              l.append('--' + boundary)
              l.append('Content-Disposition: form-data; name="%s"' % k)
              l.append('')
              l.append(v)
          for (k, f, v) in files:
              l.append('--' + boundary)
              l.append('Content-Disposition: form-data; name="%s"; filename="%s"' % (k, f))
              l.append('Content-Type: %s' % self.__getContentType(f))
              l.append('')
              l.append(v)
          l.append('--' + boundary + '--')
          l.append('')
          body = crlf.join(l)
  
          return boundary, body
docs: fields is a sequence of (name, value) elements for regular form fields.
          files is a sequence of (name, filename, value) elements for data to be uploaded as files
          Return (content_type, body) ready for httplib.HTTP instance