<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Jesper Steen Steffensen wrote:
<blockquote
 cite="mid69e3864a0607281515t6ee4d837y502d7b4b0bb9d23e@mail.gmail.com"
 type="cite">
  <div><span class="gmail_quote"></span>
  <blockquote class="gmail_quote"
 style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Give
more info.&nbsp;&nbsp;Define qry_user_roles and qry_roles as part of your
    <br>
question.<br>
    <br>
Why are you using DTML?&nbsp;&nbsp;Its a *dying art*.&nbsp;&nbsp;I can hardly look at it<br>
anymore :-)<br>
    <br>
DTML is depreciated in Zope (I think) and new people should go right to<br>
Page Templates and Python Scripts (Im sure).
    <br>
Can you code this in a Python Script?<br>
    <br>
David<br>
    <br>
    <br>
  </blockquote>
  </div>
qry_user_roles and qry_roles are two ZSQL methods that both contain
data fields called 'role'. They both work fine on my pages apart from
the nesting. One qry holds all possible roles in the system - the other
one associates roles to users. I need the dtml-if to insert the word
"selected" in a html drop-down box, so that the users role will be
selected when the drop-down box displays:
  <br>
  <br>
This will iterate over the roles and build the drop-down box:<br>
  <br>
&lt;select&gt;<br>
&lt;dtml-in qry_roles&gt;<br>
&lt;option&gt;&lt;dtml-var role&gt;&lt;/option&gt;<br>
&lt;/dtml-in&gt;<br>
&lt;/select&gt;<br>
  <br>
This should display the proper value as well: <br>
  <br>
&lt;select&gt;<br>
&lt;dtml-in qry_roles prefix="outer"&gt;<br>
&lt;option<br>
  <br>
&nbsp;&nbsp;&nbsp;&nbsp; &lt;dtml-in qry_users_roles&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp; &lt;dtml-if expr="outer_role==role"&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp; selected<br>
&nbsp;&nbsp;&nbsp;&nbsp; &lt;/dtml-if&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp; &lt;/dtml-in&gt;<br>
  <br>
&gt;&lt;dtml-var role&gt;&lt;/option&gt;
  <br>
&lt;/dtml-in&gt;<br>
&lt;/select&gt;<br>
  <br>
I'm 1 month into Zope now, so this is just what I've read from the Zope
bible/ web etc. so far ...<br>
  <br>
Is dtml really dead?!? :-o<br>
&nbsp;Shame - I like it.. Will read more about page templates then ;-)
  <br>
</blockquote>
Hi Jesper,<br>
<br>
I guess Jonathan does have a point.&nbsp; DTML is NOT DEAD as in NOT
BREATHING.&nbsp; And its true that Zope will continue DTML well into Zope 3.<br>
<br>
But its expertise "base" is fading.&nbsp; I last used it 2 years ago.&nbsp; Many
of us just don't use it anymore.&nbsp; <br>
<br>
Most still use it because of legacy code.&nbsp; <br>
<br>
I don't think Jonathan would recommend it to a newbie?<span
 class="moz-smiley-s1"><span> :-) </span></span><br>
<br>
Python + zpt is a clearer model.&nbsp; <br>
<br>
Here is some code to consider if you want to try the Page Template +
python way ...<br>
<br>
# --------------------------------<br>
# The python way (untested)<br>
# --------------------------------<br>
<br>
outer = context.SQL.qry_user_roles()<br>
inner = context.SQL.qry_roles()<br>
options = ''<br>
for o in outer:<br>
&nbsp;&nbsp; for i in inner:<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if o.role == i.role:<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; options += '\n&lt;option value="' + i.role + '"&gt;' + i.role
+ '&lt;/option&gt;'<br>
<br>
return '&lt;select&gt;' + options + '&lt;/select&gt;'<br>
<br>
# --------------------------------<br>
# in ZPT<br>
# --------------------------------<br>
<br>
&lt;tal:sel tal:replace="structure
python:context.python.pyRolesSelect()"&gt;<br>
&lt;/tal:sel&gt;<br>
<br>
<br>
I will say that learning Page Templates will give you fits for a week
or two.&nbsp; But stick with it. <br>
<br>
David<br>
<br>
<br>
<br>
<br>
<br>
</body>
</html>