[Zope] Acquisition Problem ?

Casey Duncan cduncan@kaivo.com
Fri, 09 Mar 2001 13:08:00 -0700


Richard Moon wrote:
> 
> Can anyone explain what's going on here - please ?
> 
> I've got a dtml method 'mydtml_1' which processes a file uploaded via a
> form - like this
> 
> <dtml-in "abcfile_read(REQUEST)">
>    <dtml-let abc_text=sequence-item>
>      <dtml-unless "_.len(abc_text)==0">
>        <dtml-var mydtml_2>
>      </dtml-unless>
>    </dtml-let>
> </dtml-in>
> 
> In the dtml method mydtml_2 I have some code like this
> 
> <dtml-var
> expr="REQUEST.set('abc_text',external_method_that_returns_hello_world(abc_text))>
> <dtml-var REQUEST>
> <dtml-var abc_text>
> 
> What happens is that the
> <dtml-var REQUEST> shows abc_text having the new value of "Hello World"
> 
> but the
> <dtml-var abc_text> shows the value as it was in mydtml_1
> 
> Presumably <dtml-var abc_text> is acquiring the value from mydtml_1.
> 
> Can anyone tell me why ?

Because the REQUEST object is always the last place checked by the
acquisition machinery.

> 
> And how to get <dtml-var abc_text> to return the value I want i.e. "Hello
> World" ?
> 

<dtml-var expr="REQUEST['abc_text']">

> This is Zope 2.2.1
> 
> (Note - if I do not put <dtml-var mydtml_2> inside the <dtml-in> and
> <dtml-let> constructs then it works as expected, e.g.
> <dtml-call "REQUEST.set('abc_text','Goodbye Forever')">
> <dtml-var mydtml_2>
> 
>   will render "Hello World" )
> 

The dtml-let tag creates a namespace at the top of the stack. This is
the first placed
checked during acquisition. Your value set in dtml-let obscures the
value in REQUEST.

hth,
-- 
| Casey Duncan
| Kaivo, Inc.
| cduncan@kaivo.com
`------------------>