SOLVED: [ZPT] path variable doesn't exist
Justin Robertson
nostrebornitsuj at hotmail.com
Tue Jan 20 06:22:28 EST 2004
<div tal:define=cid request/cid | nothing>
<div tal:define=tid request/tid | nothing>
<div tal:condition="python:cid and tid">
Only show me if cid and tid exist.
</div>
</div>
>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
:
_________________________________________________________________
Stay in touch with absent friends - get MSN Messenger
http://www.msn.co.uk/messenger
More information about the ZPT
mailing list