[Zope] Can't nest dtml-in using prefix ...

David H bluepaul at earthlink.net
Fri Jul 28 19:05:47 EDT 2006

Jesper Steen Steffensen wrote:

>     Give more info.  Define qry_user_roles and qry_roles as part of your
>     question.
>     Why are you using DTML?  Its a *dying art*.  I can hardly look at it
>     anymore :-)
>     DTML is depreciated in Zope (I think) and new people should go
>     right to
>     Page Templates and Python Scripts (Im sure).
>     Can you code this in a Python Script?
>     David
> 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:
> This will iterate over the roles and build the drop-down box:
> <select>
> <dtml-in qry_roles>
> <option><dtml-var role></option>
> </dtml-in>
> </select>
> This should display the proper value as well:
> <select>
> <dtml-in qry_roles prefix="outer">
> <option
>      <dtml-in qry_users_roles>
>      <dtml-if expr="outer_role==role">
>      selected
>      </dtml-if>
>      </dtml-in>
> ><dtml-var role></option>
> </dtml-in>
> </select>
> I'm 1 month into Zope now, so this is just what I've read from the 
> Zope bible/ web etc. so far ...
> Is dtml really dead?!? :-o
>  Shame - I like it.. Will read more about page templates then ;-)

Hi Jesper,

I guess Jonathan does have a point.  DTML is NOT DEAD as in NOT 
BREATHING.  And its true that Zope will continue DTML well into Zope 3.

But its expertise "base" is fading.  I last used it 2 years ago.  Many 
of us just don't use it anymore. 

Most still use it because of legacy code. 

I don't think Jonathan would recommend it to a newbie? :-)

Python + zpt is a clearer model. 

Here is some code to consider if you want to try the Page Template + 
python way ...

# --------------------------------
# The python way (untested)
# --------------------------------

outer = context.SQL.qry_user_roles()
inner = context.SQL.qry_roles()
options = ''
for o in outer:
   for i in inner:
      if o.role == i.role:
         options += '\n<option value="' + i.role + '">' + i.role + 

return '<select>' + options + '</select>'

# --------------------------------
# in ZPT
# --------------------------------

<tal:sel tal:replace="structure python:context.python.pyRolesSelect()">

I will say that learning Page Templates will give you fits for a week or 
two.  But stick with it.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.zope.org/pipermail/zope/attachments/20060728/cddfd344/attachment.htm

More information about the Zope mailing list