[Zope] Big Downloads via Python Script

Jens Fellenberg jens.fellenberg@ion-tof.com
Tue, 19 Feb 2002 14:50:07 +0100


Hi,

I have the following problem. I want to manage Downloads trough a python
script, that checks, if the user has permissions to download this file
and then reads this file and returns it to Zope. But when I want to
download files, that are bigger than 5 MB it tells me, that the file
does not exist.
Here's the part of the python script that reads the file. Name is the
path to the desired file and the filename:

def readfile(Name):
    if os.path.isdir(Name): return 0
    if not os.path.exists(Name): return 0
    f=open(Name, "rb")
    d = f.read()
    f.close()
    return d

And that's the part of the zope DTML document:

<dtml-let Download="here is the call for the python function that at
first checks the users permissions and then reads the file">
<dtml-if "Download!=0"><dtml-call "RESPONSE.setHeader('Content-Type',
guessMimeType(_['Desire']))"><dtml-var Download><dtml-else>
        <dtml-var standard_html_header>
            <center>
                <font color="#FF0000">Sorry, no such File (<dtml-var
"_['Desire']">) in <dtml-var "_['area']"> Area</font>
                <form name=dummy>
                    <input type=button name=back value="back"
onClick="document.location='DownloadArea'">
                </form>
            </center>
        <dtml-var standard_html_footer>
    </dtml-if>
</dtml-let>

Hope you can help me.

Jens Fellenberg