[Zope] Extracting query string parameters from a URL

J Cameron Cooper jccooper@jcameroncooper.com
Fri, 07 Mar 2003 19:17:08 -0600


>
>
>Hello. Does anyone know how to extract query string
>parameters from a URL? I am trying to limit access of
>a DTML page to users who have a particular user name
>and id. Users who try to access this page have to
>enter something of the sort:
>
>http://localhost:8080/somepage.html?user_name=someuser+userid=djje
>
>Is there someway to access the values associated with
>username and userid in the URL above? Any help would
>be greatly appreciated. Thanks.
>
These are automatically parsed by Zope and are available in the REQUEST 
object. This is in the namespace of DTML by default, and available in 
Python scripts and ZPT as well. The following will all print the value 
of user_name from your example:

DTML: <dtml-var user_name>
script: print container.REQUEST.user_name
ZPT: <span tal:content="request/a"

However, I think you would be better off using Zope's security machinery 
instead. And I also think it would be time well spent for you to read 
the Zope Book, to get this sort of basic stuff out of the way.

       --jcc