Today i've got a problem with the dtml-with tag, as follows: I was trying to set a variable, using REQUEST.set inside a dtml-in, inside a dtml-with, but it only works the first time i call REQUEST.set. Subsequent calls do not modify the variable, and do not raise an exception. Not even a simple error. I dont know how it was supposed to work, but i think that if the REQUEST was immutable inside a dtml-with, it should be not allowed to call REQUEST.set inside it. Here goes some example code: <dtml-with REQUEST> ... ... <snip> ... ... <dtml-in some-list> <dtml-if condition> <dtml-call "REQUEST.set('var', sequence-item)"> <== only works first time it gets called and dont raise an error. ... ... </dtml-with> See ya! -- Sidnei da Silva X3ng Consultoria e Desenvolvimento Ltda. sidnei@x3ng.com.br
On Tue, 23 Oct 2001, Sidnei da Silva wrote:
I dont know how it was supposed to work, but i think that if the REQUEST was immutable inside a dtml-with, it should be not allowed to call REQUEST.set inside it.
It isn't immutable. The second and subsequent sets should work.
<dtml-call "REQUEST.set('var', sequence-item)"> <== only works first time it
Well, I don't know quite what you are observing, but this code is broken. Inside the quotes you are in python mode, and 'sequence-item' in python mode is the variable sequence minus the variable item. Since it didn't throw an error, you must have variables by those names that understand substraction. Try _.getitem('sequence-item') instead. I suspect this thread belongs on zope, not zope-dev. --RDM
Its the <dtml-with REQUEST>, that mucks up the namespace lookup for "value" <dtml-with REQUEST> <dtml-in "[1,2,3]"> <dtml-call "REQUEST.set('value', _['sequence-item'])"> Doesnt work:<dtml-var value>, works: <dtml-var "REQUEST['value']"> </dtml-in> </dtml-with> But with REQUEST is a rather wierd thing to do. Are you sure you want to do that? Cheers. -- Andy McKay. ----- Original Message ----- From: "R. David Murray" <bitz@bitdance.com> To: "Sidnei da Silva" <sidnei@x3ng.com.br> Cc: <zope-dev@zope.org> Sent: Tuesday, October 23, 2001 3:15 PM Subject: Re: [Zope-dev] BUG or FEATURE?
On Tue, 23 Oct 2001, Sidnei da Silva wrote:
I dont know how it was supposed to work, but i think that if the REQUEST was immutable inside a dtml-with, it should be not allowed to call REQUEST.set inside it.
It isn't immutable. The second and subsequent sets should work.
<dtml-call "REQUEST.set('var', sequence-item)"> <== only works first time it
Well, I don't know quite what you are observing, but this code is broken. Inside the quotes you are in python mode, and 'sequence-item' in python mode is the variable sequence minus the variable item. Since it didn't throw an error, you must have variables by those names that understand substraction.
Try _.getitem('sequence-item') instead.
I suspect this thread belongs on zope, not zope-dev.
--RDM
_______________________________________________ Zope-Dev maillist - Zope-Dev@zope.org http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )
Yes. I was having problem with zope getting values from a property with the same name as a field of a form ive submitted instead of the request. So, using <dtml-with REQUEST> solved the problem, but then there is this problem. But i still dont understand why the first time i call REQUEST.set, and use <dtml-var variable> the variable has the value i set, and subsequent calls to REQUEST.set modify REQUEST['variable'] but not variable. This is not right for what i think. Or it modify the variable ALL the times or NONE. Do you agree? Em Tuesday 23 October 2001 20:37, Andy McKay escreveu:
Its the <dtml-with REQUEST>, that mucks up the namespace lookup for "value"
<dtml-with REQUEST> <dtml-in "[1,2,3]"> <dtml-call "REQUEST.set('value', _['sequence-item'])"> Doesnt work:<dtml-var value>, works: <dtml-var "REQUEST['value']"> </dtml-in> </dtml-with>
But with REQUEST is a rather wierd thing to do. Are you sure you want to do that?
Cheers.
-- Sidnei da Silva X3ng Consultoria e Desenvolvimento Ltda. sidnei@x3ng.com.br
On Wed, 24 Oct 2001, Sidnei da Silva wrote:
But i still dont understand why the first time i call REQUEST.set, and use <dtml-var variable> the variable has the value i set, and subsequent calls to REQUEST.set modify REQUEST['variable'] but not variable. This is not right for what i think. Or it modify the variable ALL the times or NONE.
Do you agree?
I agree. It looks like a bug to me <grin>. I think the correct behavior would be for all the sets to work, regardless of the with. My guess is that if you look in the code you'll find some weird interaction happening between the namespace stack code and acquisition. And by the way, I was under the impression that the <dtml-with REQUEST> idom was a pretty common way to handle just the case you chose it for. In fact, I think that idom appears in DC code here and there, though I could be misremembering that part. --RDM
participants (3)
-
Andy McKay -
R. David Murray -
Sidnei da Silva