Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #7069
| References | <efa25bc5-a115-4c4f-869e-91eb423d0754@j23g2000yqc.googlegroups.com> |
|---|---|
| Date | 2011-06-05 21:26 -0700 |
| Subject | Re: CGI: remove variable from Tuple Object query |
| From | Chris Rebert <clp2@rebertia.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.2481.1307334392.9059.python-list@python.org> (permalink) |
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
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
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
csiph-web