CGI-problem

Steve Holden sholden at holdenweb.com
Thu Jan 24 09:36:34 EST 2002


<olav.viken at kmss.no> wrote in message
news:a2od3t$qr5$1 at oslo-nntp.eunet.no...
> Hi!
>
> I'm having a problem passing the '#-character' to a cgi-script.
>
> The cgi script is invoked with a url as this:
>
> http:/myserver/script.py?link="T:/test.htm#Mark"
>
>
>
> Here part of my python-script
>
> import cgi,string,os
>
> all_values=cgi.FieldStorage()
> link=all_values["link"].value
> print link
>
> this will produce output:
>
> "T:/test.htm
>
>
> So my question is:  How can I get the rest of the input string?

Further to Jason's and Joonas' posts, the *reason* for this apparently
bizarre requirement is that any URL may end in a fragment beginning with an
octothorp (pound sign, hash mark, call it what you will). Such a fragment is
an instruction to the client to move to the location in the server's output
stream (if any) containing an anchor with an appropriate NAME attribute.

In your case the browser is sending

    /script.py?link="T:/test.htm

as the URi in the request (look out, by the way: non-matching quotes after
the truncation, and you forgot a slash after the "http:/" which was probably
just a typo, then looking for

    <A NAME='Mark"'> ... </A>

in the output. If it doesn't find it, it will jut display the output from
the beginning.

regards
 Steve
--
Consulting, training, speaking: http://www.holdenweb.com/
Python Web Programming: http://pydish.holdenweb.com/pwp/








More information about the Python-list mailing list