The logic of the _ variable (Q1959)
Hi, I'm trying to have a deeper understanding of the use of the _ variable, so I tried the following tests: In a folder Collection, I have two DTML Methods: 'test' and 'index_html'. test code result <dtml-var index_html> The index_html is diplayed <dtml-var "_['index_html']"> Same as previous line <dtml-var "index_html"> The code index_html is diplayed <dtml-var "PARENTS"> [[<Folder instanc...., ...] <dtml-var PARENTS> Same as previous test <dtml-var "_['PARENTS']"> Same as previous test <dtml-var PARENTS[0]> Key Error (as expected) <dtml-var "PARENTS[0]"> <Folder instance at 00B30CE0> <dtml-var "_['PARENTS'][0]"> Same as previous line <dtml-var "_['PARENTS'][0].index_html"> The code index_html is diplayed <dtml-var "PARENTS[0].index_html"> Same as previous test I would like to if there is a way to display the index_html Method (not the code) without the 'with' tag. Second question: is ther a way to access a Zope Site without worrying about the case in the URL ie: mysite/Welcome would be as mysite/WELCOME, mysite/wElCoMe and so on... and think it is important for end user comfort. Thank for your help. *************************** Oscar Picasso picasso@videotron.ca ***************************
On Thu, 16 Sep 1999 picasso@videotron.ca wrote:
Second question: is ther a way to access a Zope Site without worrying about the case in the URL ie: Well, you could patch the Folder object ;) mysite/Welcome would be as mysite/WELCOME, mysite/wElCoMe and so on... and think it is important for end user comfort. 1.) URLs usually are case sensitive. (Guess which system the www developed on ;) ) So your users should better be capable of typing an URL. 2.) What about french? Do you map the accents also automatically. What about german umlauts? etc.
Andreas -- Andreas Kostyrka | andreas@mtg.co.at phone: +43/1/7070750 | phone: +43/676/4091256 MTG Handelsges.m.b.H. | fax: +43/1/7065299 Raiffeisenstr. 16/9 | 2320 Zwoelfaxing AUSTRIA
Here's some basics, to the best of my understanding: <dtml-var x> and <dtml-var "_['x']"> should always be identical, and should render 'x'. If 'x' is a function or method, it will be called. You can also spell this <dtml-var "_.getitem('x', 1)"> <dtml-var "x"> should give a string representation of the contents of 'x'. If 'x' is a string or number, this is straightforward and the same as <dtml-var x>. If 'x' is an object, the result will often be like "<CLASS instance at ADDRESS>". Some objects define alternate string representations; DTML objects simply return their DTML code. You can also spell this <dtml-var "_.getitem('x', 0)"> You can get at properties or sub-objects of 'x' using <dtml-with x><dtml-var y></dtml-with> or <dtml-var "x.y"> or <dtml-var "_.getattr(x, 'y')">. ----- Original Message ----- From: <picasso@videotron.ca>
I'm trying to have a deeper understanding of the use of the _ variable
Thank you for your explanations. However, I found a different results when using the following syntaxes:
You can get at properties or sub-objects of 'x' using <dtml-with x> <dtml-var y> </dtml-with> or <dtml-var "x.y"> or <dtml-var "_.getattr(x, 'y')">.
The first, with the tag with render the object (in my case a DTML Method), the two others <dtml-var "x.y"> or <dtml-var "_.getattr(x, 'y')"> display a string representation of the object. So as I understand it, we have to use the tag 'with' if we want to call a subobject. *************************** Oscar Picasso picasso@videotron.ca ***************************
participants (3)
-
Andreas Kostyrka -
Evan Simpson -
picasso@videotron.ca