[ZPT] path variable doesn't exist

Justin Robertson nostrebornitsuj at hotmail.com
Tue Jan 20 06:03:03 EST 2004


Thanks very much for your post Clemens but as yet no joy.

request.cid and request.form.get('cid') raise attribute errors and 
request.form['cid'] raises a key error. This is only my second day using 
Zope and I'm amazed by the lack of documentation. Where, for instance, can I 
find a full list of the properties of the built-in objects, like 
request.form, etc?

thanks again


>From: Clemens Robbenhaar <robbenhaar at espresto.com>
>Reply-To: robbenhaar at espresto.com
>To: "Justin Robertson" <nostrebornitsuj at hotmail.com>
>CC: zpt at zope.org
>Subject: [ZPT] path variable doesn't exist
>Date: Tue, 20 Jan 2004 11:02:09 +0100
>
>
>Hi Justin,
>
>  > What is the easy way to get round the error generated when a path 
>variable
>  > that doesn't exist is referred to? I'm trying to detect an optional
>  > querystring argument, but when it's not there I get an error for 
>referring
>  > to it.
>
>  I cannot answer the general question (however as it seems that You are
>using python expressions here, 'getattr' may be your friend).
>
>  For request variables passed via HTTP, I prefer to look them up in the
>"form" attribute of the request, i.e. instead of:
>
>  >
>  > This is the code that generates the error when one or both of cid and 
>tid
>  > are not in the querystring.
>  >
>  > <div tal:condition="python:request.cid and request.tid">
>  > Only show me if cid and tid exist.
>  > </div>
>
>I would try: request.form['cid'] (which still creates an error, however)
>or
>
>    request.form.get('cid','')
>
>(where the second argument can be omitted and defaults to "None" aka
>nothing)
>
>The "form" attribute even contains the HTTP-parameter if its not a form
>posting but passed via usual '?cid=something&tid=something+different'
>notation in the URL.
>
>hope this helps,
>clemens

_________________________________________________________________
It's fast, it's easy and it's free. Get MSN Messenger today! 
http://www.msn.co.uk/messenger




More information about the ZPT mailing list