Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #7067 > unrolled thread

CGI: remove variable from Tuple Object query

Started byGnarlodious <gnarlodious@gmail.com>
First post2011-06-05 20:55 -0700
Last post2011-06-05 21:26 -0700
Articles 2 — 2 participants

Back to article view | Back to comp.lang.python


Contents

  CGI: remove variable from Tuple Object query Gnarlodious <gnarlodious@gmail.com> - 2011-06-05 20:55 -0700
    Re: CGI: remove variable from Tuple Object query Chris Rebert <clp2@rebertia.com> - 2011-06-05 21:26 -0700

#7067 — CGI: remove variable from Tuple Object query

FromGnarlodious <gnarlodious@gmail.com>
Date2011-06-05 20:55 -0700
SubjectCGI: remove variable from Tuple Object query
Message-ID<efa25bc5-a115-4c4f-869e-91eb423d0754@j23g2000yqc.googlegroups.com>
Say I send a request like this:
http://0.0.0.0/Sectrum/Gnomon?see=Gnomon&order=7&epoch=1303541219

This makes for a CGIform of the CGI Tuple Object type:
FieldStorage(None, None, [MiniFieldStorage('see', 'Gnomon'),
MiniFieldStorage('order', '7'), MiniFieldStorage('epoch',
'1303541219.58')])

So the above query should end up as:
FieldStorage(None, None, [MiniFieldStorage('order', '7'),
MiniFieldStorage('epoch', '1303541219.58')])

Is there an easy way to remove the first variable from the object? Or
am I stuck with using urllib.parse.urlparse(query)?

-- Gnarlie

[toc] | [next] | [standalone]


#7069

FromChris Rebert <clp2@rebertia.com>
Date2011-06-05 21:26 -0700
Message-ID<mailman.2481.1307334392.9059.python-list@python.org>
In reply to#7067
On Sun, Jun 5, 2011 at 8:55 PM, Gnarlodious <gnarlodious@gmail.com> wrote:
> Say I send a request like this:
> http://0.0.0.0/Sectrum/Gnomon?see=Gnomon&order=7&epoch=1303541219
>
> This makes for a CGIform of the CGI Tuple Object type:
> FieldStorage(None, None, [MiniFieldStorage('see', 'Gnomon'),
> MiniFieldStorage('order', '7'), MiniFieldStorage('epoch',
> '1303541219.58')])
>
> So the above query should end up as:
> FieldStorage(None, None, [MiniFieldStorage('order', '7'),
> MiniFieldStorage('epoch', '1303541219.58')])
>
> Is there an easy way to remove the first variable from the object?
> Or am I stuck with using urllib.parse.urlparse(query)?

For whatever reason, FieldStorage does not appear to make provision
for item deletion. However, it should be easy to monkeypatch in a
__delitem__ method or write an equivalent external function; just
iterate through and modify the `list` attribute of the FieldStorage
instance. FieldStorage's source, particularly the non-parsing-related
parts, is relatively straightforward:
http://hg.python.org/cpython/file/default/Lib/cgi.py

Cheers,
Chris
--
http://rebertia.com

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web