[Zope] Composing variables

Cristi Barladeanu kristache at gmail.com
Fri Jul 29 13:14:14 EDT 2005


Thank you all very much for your answers. 
The second solution that Jo provided worked exactly as I wanted:

.. tal:content="python: getattr(obj, 'Title_%s'%lang)"..

A good day to you all,
Cristi

On 7/29/05, Jonathan <dev101 at magma.ca> wrote:
> 
> I don't know if this is what you are looking for, but can use a form of 
> indirection that is available thru dtml:
>  <dtml-call "REQUEST.set('a1', 'aaa')">
> <dtml-call "REQUEST.set('b1', 'a1')">
>  <dtml-var b1>
> <br>
> <dtml-var "_[b1]">
> will print:
>  a1 
> aaa 
>  This will allow you to load variable b1 within a 'pointer' to a variable 
> containing the data you want.
>   hth 
>  Jonathan
>   
> ----- Original Message ----- 
> *From:* Cristi Barladeanu <kristache at gmail.com> 
> *To:* Andreas Jung <lists at andreas-jung.com> 
> *Cc:* zope at zope.org 
> *Sent:* Friday, July 29, 2005 12:02 PM
> *Subject:* Re: [Zope] Composing variables
> 
> Hello Andreas and thank for your answer. I've posted this question to 
> at-users
> list too but still no answer. In fact this problem is not related only to 
> AT. Let me 
> give you an example:
> 
> var alternative = 'bar' or 'baz'
> var foo_baz = 'content based on baz'
> var foo_bar = 'content based on bar'
> 
> These can be defined either in ZPT, DTML or Python Script. The problem is 
> the same.
> The question is how can I obtain the value of foo_$alternative.
> 
> An example written in PHP:
> 
> $alternative = "bar";
> $foo_bar = "content based on bar";
> echo ${"foo_".$alternative} 
> 
> This will produce "content based on bar".
> 
> Thanks for your time,
> Cristi
> 
> On 7/28/05, Andreas Jung <lists at andreas-jung.com> wrote: 
> > 
> > 
> > 
> > --On 28. Juli 2005 11:59:09 +0300 Cristi Barladeanu <kristache at gmail.com
> > >
> > wrote:
> > 
> > > Good day everyone
> > >
> > > I've defined some archetypes that contain fields like Title_en, 
> > Title_de, 
> > > Content_en, Content_de, etc.
> > > Assuming that I've set a language var related to URL like (lang = 
> > 'en'),
> > > how can i access them?
> > >
> > 
> > Please ask AT related questions on the at-users list. In general you 
> > should 
> > not access attributes in AT directly but only through the accessor 
> > methods.
> > There is something like getField(fieldname) in the AT which might help 
> > you
> > (look also at the AT docs).
> > 
> > -aj
> > 
> > 
>  ------------------------------
> 
> _______________________________________________
> Zope maillist - Zope at zope.org
> http://mail.zope.org/mailman/listinfo/zope
> ** No cross posts or HTML encoding! **
> (Related lists - 
> http://mail.zope.org/mailman/listinfo/zope-announce
> http://mail.zope.org/mailman/listinfo/zope-dev )
> 
> 
> _______________________________________________
> Zope maillist - Zope at zope.org
> http://mail.zope.org/mailman/listinfo/zope
> ** No cross posts or HTML encoding! **
> (Related lists -
> http://mail.zope.org/mailman/listinfo/zope-announce
> http://mail.zope.org/mailman/listinfo/zope-dev )
> 
> 
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.zope.org/pipermail/zope/attachments/20050729/02605c92/attachment.htm


More information about the Zope mailing list