Die Suche ergab 6 Treffer

von nho
Freitag 26. September 2014, 06:50
Forum: Netzwerkprogrammierung
Thema: Python return filelike object download
Antworten: 11
Zugriffe: 67344

Re: Python return filelike object download

Weil ich nicht weiß wie das geht :( wie kann ich mit js auf den return Wert der Python Funktion (in dem Fall dann die Datei selber) zugreifen und diese in einen Link verwandeln?
von nho
Donnerstag 25. September 2014, 14:30
Forum: Netzwerkprogrammierung
Thema: Python return filelike object download
Antworten: 11
Zugriffe: 67344

Re: Python return filelike object download

weil die export Datei erst erstellt werden muss, das geschieht in der Python Funktion. Dort wird ein temporäres File erstellt, mit den Daten befüllt und anschließend soll sie downloadbar sein.

Gibt es eine direkte Methode auf diese Funktion über JS zuzugreifen?
von nho
Donnerstag 25. September 2014, 13:37
Forum: Netzwerkprogrammierung
Thema: Python return filelike object download
Antworten: 11
Zugriffe: 67344

Re: Python return filelike object download

das ganze sieht folgendermaßen aus:

Ich habe eine html datei mit einem Formular:


<form id="initexport" action="path/startExport" method="post">
<input type="hidden" id="dataformat" value="xml" name="dataformat">
</form>

diese Formular wird mit JS submitted:

exportwindow.document ...
von nho
Mittwoch 24. September 2014, 13:59
Forum: Netzwerkprogrammierung
Thema: Python return filelike object download
Antworten: 11
Zugriffe: 67344

Re: Python return filelike object download

ok ich habe der Datei jetzt eine ID zugewiesen bzw. kann man mit zf.filename auch auf den namen des zipfile zugreifen..

das eigentliche Problem ist, dass ich nicht weiß wie ich zwischen Python und JS interagieren kann.. gibt es eine möglichkeit, an der stelle wo ich das Form submitte (und durch die ...
von nho
Mittwoch 24. September 2014, 08:59
Forum: Netzwerkprogrammierung
Thema: Python return filelike object download
Antworten: 11
Zugriffe: 67344

Re: Python return filelike object download

ok das klingt logisch, was ich bisher habe:


sf = tempfile.NamedTemporaryFile("w+b", suffix=".zip", dir = "/mypath")
zf = zipfile.ZipFile(sf, "w", zipfile.ZIP_DEFLATED)
zf.write(...)
downloadlink = '<a href="zf">your file</a>'
REQUEST.RESPONSE.appendBody(downloadlink)

das funktioniert soweit ...
von nho
Mittwoch 24. September 2014, 08:35
Forum: Netzwerkprogrammierung
Thema: Python return filelike object download
Antworten: 11
Zugriffe: 67344

Python return filelike object download

Hallo zusammen!

Ich habe ein filelike object (zipfile.ZipFile), das ich aus einer Pyhton Funktion zurück bekomme und müsste diese nun in einer HTML Seite als downoadlink bereitstellen. Hat jemand eine Idee wie man das machen kann?

Das ganze sieht folgendermaßen aus: Ich habe ein HTML Seite mit ...