[Zope] DTML Question Continued

Dieter Maurer dieter@handshake.de
Wed, 15 Jan 2003 23:36:24 +0100


beno wrote at 2003-1-15 04:26 -0400:
 > This is becoming far_more_complex than I anticipated. I would love to be 
 > able to do something like this:
 > 
 > <dtml-let lang="REQUEST.get('HTTP_ACCEPT_LANGUAGE','en-us')">
 >   <dtml-in objectValues>
 >    <dtml-let folder=id>
 >     <dtml-let langShort=lang[2:]>
 >      <dtml-var langShort>
 >      <dtml-if expr="folder==lang">
 >       <dtml-var lang>
 >      </dtml-if>
 >     </dtml-let>
 >    </dtml-let>
 >   </dtml-in>
 > </dtml-let>
This cries for an implementation in a Python script!

 > but there are two problems here:
 > 1) Apparently I can't slice in DTML;
You can but you should use "..." on the right side of "=" (in "dtml-let")
when it is an expression.

I suggest again some background reading....

 > 2) The expression "folder==lang" evaluates the literal strings, not the 
 > variables.
What do you mean with "literal string".
"folder == lang" compares the values bound to "folder" and "lang"
for equality.
It does not compare the strings 'folder' and 'lang'.

 > The second problem is probably far less difficult than the first. The first 
 > seems to necessitate I do this as a Python script. That being the case, it 
 > seems logical to do the objectValues iteration in the same script. So, how 
 > do I do that? Looking at Appendix B, I find *propertyIds()* as a likely 
 > method. What would my syntax be? Something like this?
You want read some Python introduction.

The Python Tutorial is said to be very good...

The iteration will look like

    for obj in context.objectValues():
      ....


Dieter