|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
SlickEdit: Code in over 40 languages across 7 platforms. SlickEdit’s unmatched power, speed, and flexibility allows even the most accomplished developers to write better code faster. Download a free trial today! |
|
#1
|
|||
|
|||
|
Pass a file from DMTL to Python script
I need to pass a file from DTML document to python script via an External Method.
Problem: the python script is not receiving the file correctly. I'm not getting an error... it's just an empty file. I have the following in my code: <...method="post" enctype="multipart/form-data"...> and the file is of <...type="file" name="thefile"...> I'm calling the external method "convert" like this: <dtml-var "convert(thefile)"> However, when I return thefile in the python script to see if it contains anything, it's returning an empty file. (I varified the contents of the file... it's not empty!!) What am I doing wrong??? Thanks.... |
|
#2
|
||||
|
||||
|
Hi, could you not run this as a python script in zope and use the request handle to get the data from the file? Or if the file is on the server already, can you read it in from the python script. What exactly is the perpos of this page anyway? If it's just file upload then I'm sure there are already a few dtml methods out there, there may even be a dtml upload tag. I'm looking into external methods ill let you know if i figure something out.
Take care, Have fun, Mark. |
|
#3
|
|||
|
|||
|
I can't run the script in Zope because of some of the imports I'm having to do. (example: from sgmllib import SGMLParser) This is why I have to use an External Method.
The purpose of the script is to convert a HTML/XML file to plain text. The DocumentLibrary in Zope allows for this conversion, but I need to do it programmatically. I'm actually using the html.py script that the DocumentLibrary uses. I allow the user to choose a file from his/her computer to convert to plain text. The problem is that when I send the file from the DTML method to the python script, it's empty when it reaches the script. I hope this explains what I'm trying to do. Thanks for your help. I really appreciate it. |
|
#4
|
||||
|
||||
|
Yeah i see, ok if i break this down. The way i see it, you have an external method which you want to send the data from the file stream. If you are passing data to a python function within the external method (dont know how you do this yet) you need to prosess the form and pass the data from the file field to the external method and then get the output (which i believe happens automatically)
Something like this but i dout this would work.. Code:
<dtml-var "convert(<dtml-var "file field">)"> Hope this helps am still trying to get my head around zope ![]() Take care, Mark. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Python Programming > Pass a file from DMTL to Python script |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|