This won't work: <dtml-in qry_user_roles prefix="outer"> <dtml-in qry_roles> <dtml-if expr="outer_role==role"> Roles are matching </dtml-if> </dtml-in> </dtml-in> I get an error that says key error - outer_role doesn't exist. It doesn't matter if I prefix the inner dtml-in as well. (I've read it isn't necessary though) Why won't the prefix work for me?
En/na Jesper Steen Steffensen ha escrit:
This won't work:
<dtml-in qry_user_roles prefix="outer"> <dtml-in qry_roles> <dtml-if expr="outer_role==role"> Roles are matching </dtml-if> </dtml-in> </dtml-in>
I get an error that says key error - outer_role doesn't exist. It doesn't matter if I prefix the inner dtml-in as well. (I've read it isn't necessary though) Why won't the prefix work for me?
maybe outer_item.role == role ? HTH
Jesper Steen Steffensen wrote:
This won't work:
<dtml-in qry_user_roles prefix="outer"> <dtml-in qry_roles> <dtml-if expr="outer_role==role"> Roles are matching </dtml-if> </dtml-in> </dtml-in>
I get an error that says key error - outer_role doesn't exist. It doesn't matter if I prefix the inner dtml-in as well. (I've read it isn't necessary though) Why won't the prefix work for me?
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
----- Original Message ----- From: "David H" <bluepaul@earthlink.net> To: "Jesper Steen Steffensen" <jsteffensen@gmail.com> Cc: <zope@zope.org> Sent: Friday, July 28, 2006 5:53 PM Subject: Re: [Zope] Can't nest dtml-in using prefix ...
Why are you using DTML? Its a *dying art*. I can hardly look at it anymore :-)
DTML is not dying. If you can not look at it that is your own choice.
DTML is depreciated in Zope (I think) and new people should go right to
DTML is not deprecated. DTML and ZPT both have their own advantages and disadvantages and different situations call for different solutions. If you have a preference for one over the other that is fine... for you. Jonathan
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 ;-)
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 + '</option>' return '<select>' + options + '</select>' # -------------------------------- # in ZPT # -------------------------------- <tal:sel tal:replace="structure python:context.python.pyRolesSelect()"> </tal:sel> I will say that learning Page Templates will give you fits for a week or two. But stick with it. David
Jesper Steen Steffensen wrote at 2006-7-28 22:27 +0200:
This won't work:
<dtml-in qry_user_roles prefix="outer"> <dtml-in qry_roles> <dtml-if expr="outer_role==role"> Roles are matching </dtml-if> </dtml-in> </dtml-in>
I get an error that says key error - outer_role doesn't exist. It doesn't matter if I prefix the inner dtml-in as well. (I've read it isn't necessary though) Why won't the prefix work for me?
The prefix affects only the "sequence-" variables (it replaces the "sequence-" prefix by "<prefix>_"). It does not do anything with the other (non "sequence-" prefixed) variables definied by the "dtml-in". -- Dieter
The prefix affects only the "sequence-" variables (it replaces the "sequence-" prefix by "<prefix>_"). It does not do anything with the other (non "sequence-" prefixed) variables definied by the "dtml-in".
Dieter
@ Dieter - thanks for clearing that up. Maybe [sequence]-var-[variable] or rather "outer-var-role" will work then.. Will give it a try when I get back to work. I'll look into ZPT as well. Sounds promising. Thanks all for helping me out here. Cheers
Jesper Steen Steffensen wrote at 2006-7-29 22:30 +0200:
... @ Dieter - thanks for clearing that up. Maybe [sequence]-var-[variable] or rather "outer-var-role" will work then.. Will give it a try when I get back to work.
I am unaware that this will work -- though I may be wrong. Usually, you would access the variables defined in the outer loop directly by their name. This will work as though the inner loop does not introduce a name conflict (which the inner loop will win). In such a case, I tend to use a "dtml-let" to define appropriate (non conflicting) aliases for problematic variable defined by the outer loop. -- Dieter
participants (5)
-
Alexis Roda -
David H -
Dieter Maurer -
Jesper Steen Steffensen -
Jonathan