Python Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPython Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
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  
Old July 15th, 2003, 03:00 PM
rshirah rshirah is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Posts: 9 rshirah User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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....

Reply With Quote
  #2  
Old July 15th, 2003, 03:56 PM
netytan's Avatar
netytan netytan is offline
Hello World :)
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Mar 2003
Location: Hull, UK
Posts: 2,529 netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 17 h 18 m 50 sec
Reputation Power: 63
Send a message via ICQ to netytan Send a message via AIM to netytan Send a message via MSN to netytan Send a message via Yahoo to netytan
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.

Reply With Quote
  #3  
Old July 16th, 2003, 08:25 AM
rshirah rshirah is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Posts: 9 rshirah User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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.

Reply With Quote
  #4  
Old July 16th, 2003, 09:30 AM
netytan's Avatar
netytan netytan is offline
Hello World :)
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Mar 2003
Location: Hull, UK
Posts: 2,529 netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 17 h 18 m 50 sec
Reputation Power: 63
Send a message via ICQ to netytan Send a message via AIM to netytan Send a message via MSN to netytan Send a message via Yahoo to netytan
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.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPython Programming > Pass a file from DMTL to Python script


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway