[Zope] Odd behaviour while searching in the namepsace

H.G.J. van der Linde linde@fsw.leidenuniv.nl
Fri, 11 Feb 2000 22:29:27 +0100


Hi,

Tres Seaver (thanks) gave me the following code to lookup a photo in the
namespace based on a value from a field (mwid) in a database.

<dtml-with psychologie>
    <dtml-with mwfoto>
       <dtml-if "_.has_key(mwid)">
           <dtml-var "_[mwid].tag()">
         <dtml-else>
              <dtml-var "geenfoto.tag()">
        </dtml-if>
    </dtml-with>
</dtml-with>

This should work but it doesn't. This however works (replacing mwid by a
fixed value).

<dtml-with psychologie>
    <dtml-with mwfoto>
       <dtml-if "_.has_key('linde')">
            <dtml-var "_['linde'].tag()">
           <dtml-else>
                <dtml-var "geenfoto.tag()">
        </dtml-if>
     </dtml-with>
</dtml-with>


I found out that  using mwid with

    <dtml-if "_.has_key(mwid)">
           <dtml-var "_[mwid].tag()">


one space is added to mwid, so I get 'linde '. This space is not in the
database, or generated by the database, I guess, because this works fine:

<img src="/psychologie/mwfoto/<dtml-var mwid>" align="right">


So what is happening here?

How do I use the (r)strip function in an expression like <dtml-if
"_.has_key(mwid)">.


Your help is much apreciated.

Henny van der Linde

Leiden University
Netherlands
linde@fsw.leidenuniv.nl