[Zope] How can I examine an property of an object from the ot her object in the other tree?

Michel Pelletier michel@digicool.com
Mon, 16 Aug 1999 16:16:15 -0400


> -----Original Message-----
> From: kslee@plaza1.snu.ac.kr [mailto:kslee@plaza1.snu.ac.kr]
> Sent: Monday, August 16, 1999 12:35 PM
> To: Michel Pelletier; zope@zope.org
> Subject: Re: [Zope] How can I examine an property of an 
> object from the
> other object in the other tree?
> 
> 
> Thank you for your reply with apology for non-plain text mail 
> & varous typos.
> 
> After a shower and your reply, I can refine my question.
> 
> As you wrote, <!--#var "english.members.test.docTest.TR"--> works OK.
>    (docTest is DTML Document and TR is its property)
> But only as far as I *hard code* into every DTML Document 
> such a line(yes there is a way to hard code such a line into 
> every DTML Document if I have to but it seems too foolish and 
> complicated).
> 
> Is there a way to write *ONE* DTML code and use it in every 
> DTML Document? 
> 

This is what acquisition is for.  Acquisition allows you to factor out
common components of your application into services available to all or
some of your objects depending on their placement in Zope reletive to
the component in question.  For your problem, create a DTML Method in
the root level folder named 'isTR' containing:

<!--#if TR-->
  English
<!--#else-->
  Korean
<!--#/if-->

Now lets say you have a DTML Document called /korean/docs/one whose TR
property is set to '0' (meaning there is no english tranlation).  Going
to /korean/docs/one/isTR will print 'Korean'.

What happened is the 'one' Document *acquired* 'isTR' from the root
folder.  It can acquire from any object 'above' it in the object
heirarchy.  By this reasoning, it stands that everything in the root
folder is acquireable.

> I wrote in the root folder an one liner DTML method 'isTRed' which is
> <!--#var "'english.'+ _.string.join( _.string.split(URL0, 
> '/')[4:], '.')+'.TR'" -->
> 
> It gives the string english.members.test.docTest.TR 
> when called in the DTML Document /korean/members/test/docTest 
> as <!--#var isTRed-->.
> 
> But <!--#var "isTRed" --> gives the source of isTRed method.
> And <!--#var "_[isTRed]"--> gives attribute error.
> <!--#var "_['isTRed']"--> gives the string 
> english.members.test.docTest.TR as might be
> expected. 
> 

You want <!--#var isTRed-->  Quoting the var argument makes it be
evaluated as an expression.  Not quoting it makes Zope use it by name.
If you quote a DTML Method or Document, you must *call* it to get it to
render the document.  In this case however, refering to the document by
name will call the document for you:

  <!--#var isTRed-->



> Please don't laugh at my silliness,  : (.
> 
> Any revelation?
> 
> TIA
> 
> LEE Kwan Soo.
> 
> 
> _______________________________________________
> Zope maillist  -  Zope@zope.org
> http://www.zope.org/mailman/listinfo/zope
> 
> (To receive general Zope announcements, see:
> http://www.zope.org/mailman/listinfo/zope-announce
> 
> For developer-specific issues, zope-dev@zope.org -
> http://www.zope.org/mailman/listinfo/zope-dev )
>