Re: [Zope] is <dtml-unless someIndirectVariable> possible ?
I have a lot of REQUEST like this one to check, depending on what documents are in the folder. <dtml-unless SOMEREQ> <dtml-call "REQUEST.set('SOMEREQ','defaultvalue')"> </dtml-unless> RH: this should work. It works with me so i gave all documents concerned 2 properties myPropName,myPropValue (in our example myPropName : SOMEREQ myPropValue : defaultvalue) So i'm able to iterate the documents and check the properties and set the REQUEST. <dtml-in "objectValues(['DTML Document'])"> <dtml-if "_.hasattr(this(), 'myPropName') == 1"> <dtml-call "REQUEST.set(myPropName,myPropValue)"> </dtml-if> </dtml-in> this works OK. But, I can't find a way to generate the <dtml-unless SOMEREQ> tag. Passing the value of myPropName seems to fail (erreur while parsing the syntax, or check the 'myPropName' instead of his value). I tried a lot of things and syntax around <dtml-unless myPropName>, but it failed. RH: Um, as you describe it, you mix up the name of the property and its value (but that might be a matter of desciption). Try something like the following <dtml-unless "myPropName==SOMEREQ"> <dtml-call "REQUEST.set('myPropName', defaultvalue)"> </dtml-unless> note that 1) this will only work if there is a myPropName and a defaultvalue variable in the namespace and 2) this won't change the value of the property hth Rik
On 27 Aug 2000, at 11:49, Rik Hoekstra <rik.hoekstra@inghist.nl> (Rik Hoekstra) wrote:
RH: Um, as you describe it, you mix up the name of the property and its value Try something like the following <dtml-unless "myPropName==SOMEREQ"> <dtml-call "REQUEST.set('myPropName', defaultvalue)"> </dtml-unless>
note that 1) this will only work if there is a myPropName and a defaultvalue variable in the namespace and 2) this won't change the value of the property
Well, i was not clear. In <dtml-unless SOMEREQ> <dtml-call "REQUEST.set('SOMEREQ','defaultvalue')"> </dtml-unless> the problem is SOMEREQ is *hard* coded in the DTML document. I need to have EXACTLY the same behaviour (checking if SOMEREQ is in the REQUEST, and set it. If i use a property (PropName) for putting the name of what i want to check (SOMEREQ in my case), only the REQUEST.set works. the <dtml-unless is checking for PropName in the REQUESt and NOT *value* of PropName So in your example, SOMEREQ is *still* hard coded. From what i understood.
(but that might be a matter of desciption). Sorry, but as you already guess it, Zope is not my native language and English either ;-< So thanks for trying to understand MY english ;->
Didier.
Try <dtml-unless "_['myPropName']">
On Sun, 27 Aug 2000, Bill Welch wrote:
<dtml-unless "_['myPropName']">
Hmm. Don't you mean _[myPropName]? I think that will throw a key error if the value of myPropName is a key in the namespace, though, which I don't think is what he wants. If the question is specifically whether or not the property is in request, then <dtml-unless "REQUEST.has_key(myPropName)"> would probably be the best approach. --RDM
participants (4)
-
Bill Welch -
Didier Georgieff -
R. David Murray -
Rik Hoekstra