473,835 Members | 1,903 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

follow-up to FieldStorage

If I want to get all the values that are entered into an HTML form and
write them to a file, is there some way to handle them all at the same
time, or must FieldStorage be indexed by each specific field name?
Jun 5 '06 #1
7 1589
John Salerno a écrit :
If I want to get all the values that are entered into an HTML form and
write them to a file, is there some way to handle them all at the same
time, or must FieldStorage be indexed by each specific field name?


AFAIK, FieldStorage is a somewhat dict-like object, but I'm not sure it
supports the whole dict interface. At least, it does support keys(), so
you should get by with:

for k in fs.keys():
print >> myfile, k, ":", fs[k]

But reading the doc may help...
Jun 5 '06 #2
Bruno Desthuilliers wrote:
John Salerno a écrit :
If I want to get all the values that are entered into an HTML form and
write them to a file, is there some way to handle them all at the same
time, or must FieldStorage be indexed by each specific field name?


AFAIK, FieldStorage is a somewhat dict-like object, but I'm not sure it
supports the whole dict interface. At least, it does support keys(), so
you should get by with:

for k in fs.keys():
print >> myfile, k, ":", fs[k]

But reading the doc may help...


Thanks. The cgi docs don't seem to get into too much detail, unless I
wasn't thorough enough. But your method seems like it might work well if
I can't find something after another read through.
Jun 6 '06 #3
John Salerno <jo******@NOSPA Mgmail.com> wrote:
Bruno Desthuilliers wrote:
John Salerno a écrit :
If I want to get all the values that are entered into an HTML form and
write them to a file, is there some way to handle them all at the same
time, or must FieldStorage be indexed by each specific field name?


AFAIK, FieldStorage is a somewhat dict-like object, but I'm not sure it
supports the whole dict interface. At least, it does support keys(), so
you should get by with:

for k in fs.keys():
print >> myfile, k, ":", fs[k]

But reading the doc may help...


Thanks. The cgi docs don't seem to get into too much detail, unless I
wasn't thorough enough. But your method seems like it might work well if
I can't find something after another read through.


On the other hand, 45 seconds with the source code shows that "class
FieldStorage" has member functions called "keys()" and "has_key()" .

Use the source, Luke. To me, that's one of the big beauties of Python.
--
- Tim Roberts, ti**@probo.com
Providenza & Boekelheide, Inc.
Jun 8 '06 #4
Tim Roberts wrote:
John Salerno <jo******@NOSPA Mgmail.com> wrote:

Bruno Desthuilliers wrote:
John Salerno a écrit :

If I want to get all the values that are entered into an HTML form and
write them to a file, is there some way to handle them all at the same
time, or must FieldStorage be indexed by each specific field name?

AFAIK, FieldStorage is a somewhat dict-like object, but I'm not sure it
supports the whole dict interface. At least, it does support keys(), so
you should get by with:

for k in fs.keys():
print >> myfile, k, ":", fs[k]

But reading the doc may help...


Thanks. The cgi docs don't seem to get into too much detail, unless I
wasn't thorough enough. But your method seems like it might work well if
I can't find something after another read through.

On the other hand, 45 seconds with the source code shows that "class
FieldStorage" has member functions called "keys()" and "has_key()" .

Use the source, Luke. To me, that's one of the big beauties of Python.


FWIW, reading the source is not even needed to know this:

Python 2.4.3 (#1, Jun 3 2006, 17:26:11)
[GCC 3.4.6 (Gentoo 3.4.6-r1, ssp-3.4.5-1.0, pie-8.7.9)] on linux2
Type "help", "copyright" , "credits" or "license" for more information.
import cgi
dir(cgi.FieldSt orage) ['FieldStorageCl ass', '_FieldStorage_ _write', '__contains__', '__doc__',
'__getattr__', '__getitem__', '__init__', '__iter__', '__len__',
'__module__', '__repr__', 'bufsize', 'getfirst', 'getlist', 'getvalue',
'has_key', 'keys', 'make_file', 'read_binary', 'read_lines',
'read_lines_to_ eof', 'read_lines_to_ outerboundary', 'read_multi',
'read_single', 'read_urlencode d', 'skip_lines']


--
bruno desthuilliers
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in 'o****@xiludom. gro'.split('@')])"
Jun 8 '06 #5
John Salerno wrote:
Bruno Desthuilliers wrote:
John Salerno a écrit :
If I want to get all the values that are entered into an HTML form and
write them to a file, is there some way to handle them all at the same
time, or must FieldStorage be indexed by each specific field name?


AFAIK, FieldStorage is a somewhat dict-like object, but I'm not sure it
supports the whole dict interface. At least, it does support keys(), so
you should get by with:

for k in fs.keys():
print >> myfile, k, ":", fs[k]

But reading the doc may help...


Thanks. The cgi docs don't seem to get into too much detail, unless I
wasn't thorough enough. But your method seems like it might work well if
I can't find something after another read through.


this any use:

http://aspn.activestate.com/ASPN/Coo...n/Recipe/81547

?

Gerard

Jun 8 '06 #6
Gerard Flanagan wrote:
John Salerno wrote:
Bruno Desthuilliers wrote:
John Salerno a écrit :
If I want to get all the values that are entered into an HTML form and
write them to a file, is there some way to handle them all at the same
time, or must FieldStorage be indexed by each specific field name?
AFAIK, FieldStorage is a somewhat dict-like object, but I'm not sure it
supports the whole dict interface. At least, it does support keys(), so
you should get by with:

for k in fs.keys():
print >> myfile, k, ":", fs[k]

But reading the doc may help...

Thanks. The cgi docs don't seem to get into too much detail, unless I
wasn't thorough enough. But your method seems like it might work well if
I can't find something after another read through.


this any use:

http://aspn.activestate.com/ASPN/Coo...n/Recipe/81547

?

Gerard

Very interesting!
Jun 8 '06 #7
bruno at modulix wrote:
FWIW, reading the source is not even needed to know this:

import cgi
dir(cgi.FieldSt orage)
not to mention:
help(cgi.FieldS torage)

Help on class FieldStorage in module cgi:

class FieldStorage
| Store a sequence of fields, reading multipart/form-data.
|
| This class provides naming, typing, files stored on disk, and
| more. At the top level, it is accessible like a dictionary, whose
| keys are the field names. (Note: None can occur as a field name.)

(followed by a detailed description of the field objects, and
descriptions of all methods on the dictionary-list object).

</F>

Jun 8 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
6535
by: Nobody | last post by:
Does anyone have some python code snippets for finding First() and Follow() sets of an LL(1) grammar handy? Thanks
9
1824
by: santanu | last post by:
Hi all, I know a little python (not the OOP part) learnt by studying the online tutorial. Now I would like to learn it more thoroughly. I have access to 'Programming Python' which I liked (on flipping through the pages), but the problem is it deals only with version 2.0 of Phython.
9
2012
by: Philip TAYLOR | last post by:
Configuring a new instance of IIS, I noticed that it allows an HTML-formatted document trailer to be appended to every document served. Unfortunately, on checking its behaviour, I find that it appends the trailer /after/ the closing </HTML> of the document, separated by a blank line. I therefore have a few questions : 1) Assuming HTML 4.01 Transitional, can anything legitimately follow the closing </HTML> tag ?
2
2063
by: Joris Gillis | last post by:
Hi everyone, I have this nasty little problem to which I can't find a solution: Consider an anchor <a name="Top" id="Top">Top</a> How can I follow/execute this link from within javascript? In other words, how can I mimic the action that occurs when a user has clicked a (non-existing) <a href="#Top">click me</a> link, so that the page will be shifted to the top (that's an example - not the actual goal) The link must be followed in the...
1
3787
by: oketz1 | last post by:
Hi I am writing an application very similar to notepad and I have to implement the status bar feature, which mean that I have to follow after the cursor is there any event that raised when cursor location change ? I have tryed the text change and the click event on text box but its not enough to follow the cursor if I am not change the text just move
3
3876
by: MPR | last post by:
Hi guys; I'm using an AxSHDocVw.AxWebBrowser control to show a web page. I need to know if i can ( and how? ) i do the following things: 1 - I need to follow 1 link in the webpage diplayed in the AxSHDocVw.AxWebBrowser control. 2 - I need to input some data in a texto box on it
0
1603
by: woodglass | last post by:
I want to use object.hyperlink.Follow to follow a hyperlink to a web page. The web page requests a username & password. Can I programmatically supply both instead of having to type them in ?. TIA, woodglass
3
3254
by: Rizvi | last post by:
The Grammer is given: S ---> id=E; E ---> E+T | E-T | T T ---> T*F | T/F | F F ---> P^F | P P ---> -P | L L ---> (E) | id | num -------------------------------- I've fond the following FIRST and FOLLOW:
0
1127
by: 008worker | last post by:
Do you want the science article you may follow the following the link. Do you want something about science?if yes you may follow the following link.it is really intresting and useful. http://scienceconcepts.googlepages.com
33
1265
by: castironpi | last post by:
I am concerned by the lack of follow-through on some responses to recent ideas I have described. Do I merely have a wrong understanding of group policy? Is it a good policy (defined with respect to the future of Python and the welfare of humans at large) if so? Is there a serious lack of diligence, or should I merely take more initiative, and ignore charges of 'pestering'? (Warning, moderately deep outside social issues on table too.)
0
9653
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10815
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10526
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10563
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9348
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7770
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6970
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5640
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4435
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.