(name, contenttype, content)
return out
A function to get data out of some content, possibly decoding it depending
    on the content type.  This function understands three types of content:
    raw (where no decoding is necessary), base64 (where the data needs to be
    base64 decoded), and url (where the data needs to be downloaded).  Because
    the data might be large, all data is sent to file handle, which is returned
    from the function.
A function to get data out of some content, possibly decoding it depending
    on the content type.  This function understands three types of content:
    raw (where no decoding is necessary), base64 (where the data needs to be
    base64 decoded), and url (where the data needs to be downloaded).  Because
    the data might be large, all data is sent to file handle, which is returned
    from the function.
A function to get data out of some content possibly decoding it depending on the content type . This function understands three types of content : raw ( where no decoding is necessary ) base64 ( where the data needs to be base64 decoded ) and url ( where the data needs to be downloaded ) . Because the data might be large all data is sent to file handle which is returned from the function .
def data_from_type(name, contenttype, content):
    '''
    A function to get data out of some content, possibly decoding it depending
    on the content type.  This function understands three types of content:
    raw (where no decoding is necessary), base64 (where the data needs to be
    base64 decoded), and url (where the data needs to be downloaded).  Because
    the data might be large, all data is sent to file handle, which is returned
    from the function.
    '''

    out = tempfile.NamedTemporaryFile()
    if contenttype == 'raw':
        out.write(content)
    elif contenttype == 'base64':
        base64.decode(StringIO.StringIO(content), out)
    elif contenttype == 'url':
        url = urlparse.urlparse(content)
        if url.scheme == "file":
            with open(url.netloc + url.path) as f:
                out.write("".join(f.readlines()))
        else:
            oz.ozutil.http_download_file(content, out.fileno(), False, None)
    else:
        raise oz.OzException.OzException("Type for %s must be 'raw', 'url' or 'base64'" % (name))

    # make sure the data is flushed to disk for uses of the file through
    # the name
    out.flush()
    out.seek(0)

    return out
def data_from_type ( name , contenttype , content ) : out = tempfile . NamedTemporaryFile ( ) if contenttype == 'raw' : out . write ( content ) elif contenttype == 'base64' : base64 . decode ( StringIO . StringIO ( content ) , out ) elif contenttype == 'url' : url = urlparse . urlparse ( content ) if url . scheme == "file" : with open ( url . netloc + url . path ) as f : out . write ( "" . join ( f . readlines ( ) ) ) else : oz . ozutil . http_download_file ( content , out . fileno ( ) , False , None ) else : raise oz . OzException . OzException ( "Type for %s must be 'raw', 'url' or 'base64'" % ( name ) ) # make sure the data is flushed to disk for uses of the file through # the name out . flush ( ) out . seek ( 0 ) return out