'Creating a new document
@param file_: An opened file(like) obj to the document
A file must be opened in \'rb\' mode'

def __init__(self, file_, mime_type=None):

    self.mime_type = mime_type
    op_sep = os.path.sep
    op_join = os.path.join
    op_isdir = os.path.isdir
    op_dirname = os.path.dirname
    self.filename = getattr(file_, 'name', None)
    if ((self.filename is None) and (mime_type is None)):
        raise ValueError('Cannot    guess    mime    type    from    such    object,    you    should    use    the    mime_type    constructor    arg.')
    if isinstance(file_, urllib.addinfourl):
        (fh, self._cache_file) = tempfile.mkstemp()
        fh = os.fdopen(fh, 'wb')
        fh.write(file_.read())
        fh.close()
        file_.close()
        file_ = open(self._cache_file, 'rb')
    self._cache_dir = tempfile.mkdtemp()
    openxmldoc = zipfile.ZipFile(file_, 'r', zipfile.ZIP_DEFLATED)
    for outpath in openxmldoc.namelist():
        rel_outpath = op_sep.join(outpath.split('/'))
        abs_outpath = op_join(self._cache_dir, rel_outpath)
        abs_outdir = op_dirname(abs_outpath)
        if (not op_isdir(abs_outdir)):
            os.makedirs(abs_outdir)
        fh = file(abs_outpath, 'wb')
        fh.write(openxmldoc.read(outpath))
        fh.close()
    openxmldoc.close()
    file_.close()
    ct_file = op_join(self._cache_dir, '[Content_Types].xml')
    self.content_types = contenttypes.ContentTypes(xmlFile(ct_file, 'rb'))
