[Zope] Re: [Projet-zf] Download a file from a form

FR Chalaoux chalaoux@cybercable.fr
Sun, 02 Apr 2000 09:46:15 +0200


Hi,

I fixed the problem :

getPDB method
=============
<dtml-var "getfiles(REQUEST, REPONSE)">

getfiles.py Extension file
===========================
def getfiles(self, REQUEST['ids'], RESPONSE):
  PickleJar = Trinket('/me/foo-ids.gz','x/gzip')
  PickleJar.download(RESPONSE)
  blah, blah ...

But now , when I save the file the filename is getPDB (getPDB method is took in
fact), not the name of my downloaded file.

Any solution ?

FR


Francois-Regis CHALAOUX wrote:

> Hi All,
>
> My problem is to download a file from a FORM. When I click on Submit button I
> would like download a file via a dialog "save as". As my following code shows
> you, ids input is not used for the moment, later I will construct the filename
> to download with this ids. But for the moment I got an error :(.
> Is it the right way to do it, what is my error, etc .. I suspect something
> with RESPONSE but I can't find something in mailing-list or doc on that stuff.
>
> Help appreciated.
>
> FR.
>
> DownloalForm
> ============
> <FORM ACTION=getPDB METHOD=POST>
> <INPUT TYPE=TEXT Name=ids>
> <INPUT TYPE=SUMBIT NAME=Submit>
>
> getPDB method
> =============
> <dtml-var "getfiles(REQUEST['ids'])">
>
> getfiles.py Extension file
> ===========================
> def getfiles(ids):
>   PickleJar = Trinket('/me/foo-ids.gz','x/gzip')
>   PickleJar.download(RESPONSE)
>
> class Trinket:
>   def __init__(self,path,type):
>     self.path,self.type = path, type
>
>   def download(self, RESPONSE):
>     RESPONSE['Content-type']=self.type
>     return open(self.path).read()
>
> Errors
> =====
> <!--
>  Error type:  NameError
>  Error value: RESPONSE
>  -->
> </BODY></HTML>
> <PRE>
> Traceback (innermost last):
>   File /usr/local/Zope-2/lib/python/ZPublisher/Publish.py, line 214, in
> publish_module
>   File /usr/local/Zope-2/lib/python/ZPublisher/Publish.py, line 179, in
> publish
>   File /usr/local/Zope-2/lib/python/Zope/__init__.py, line 201, in
> zpublisher_exception_hook
>     (Object: ElementWithAttributes)
>   File /usr/local/Zope-2/lib/python/ZPublisher/Publish.py, line 165, in
> publish
>   File /usr/local/Zope-2/lib/python/ZPublisher/mapply.py, line 160, in mapply
>     (Object: getPDB)
>   File /usr/local/Zope-2/lib/python/ZPublisher/Publish.py, line 102, in
> call_object
>     (Object: getPDB)
>   File /usr/local/Zope-2/lib/python/OFS/DTMLMethod.py, line 145, in __call__
>     (Object: getPDB)
>   File /usr/local/Zope-2/lib/python/DocumentTemplate/DT_String.py, line 502,
> in __call__
>     (Object: getPDB)
>   File /usr/local/Zope-2/lib/python/DocumentTemplate/DT_Util.py, line 321, in
> eval
>     (Object: getfiles(REQUEST['ids']))
>   File &lt;string&gt;, line 0, in ?
>   File /usr/local/Zope-2/lib/python/Products/ExternalMethod/ExternalMethod.py,
> line 246, in __call__
>     (Object: getfiles)
>     (Info: (('eeee',), {}, None))
>   File /usr/local/Zope-2/Extensions/getfiles.py, line 3, in getfiles
> NameError: (see above)
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> _______________________________________________
> Projet-zf mailing list  -  Projet-zf@zope-france.org
> http://www.zope-france.org/mailman/listinfo/projet-zf