[albatross-users] more data tricks for the wiki

Eric S. Johansson esj at harvee.org
Thu Jul 3 10:29:55 EST 2003


well, I fumbled along somemore and generated this little tidbit (telepathy bit 
turned on):

Assume you have a collection of data that you want displayed on a web page.  it 
really doesn't matter what the collection is for as long as it is a logical set 
of data extracted from a list of these sets by the <al-for> statement.

Usual usage patterns are will yield a statement like:

<al-for iter="item" expr="list">

where list is the list of sets and item is a single element from the list.  If 
the individual item was a simple string, integer, or float them the value would 
be made accessible by the .value() method.  The reason for this indirect method 
of data retrieval is that item is not what you put on the list in the first 
place.  It is instead an object which contains one of the objects you put on to 
"list".

However, in this circumstance the data contained in each element of "list" is 
more complicated.  It can be a tuple, object, or even a list of lists.  In this 
case, accessing the real data comes after .value() such as:

item.value().status

which would return the data on the field/attribute called status.  While this 
form is okay for a couple of references, it quickly gets tedious.  Instead, it's 
possible to reassign the value of item to another variable and then use that 
other variable as the base for referencing the various fields of the real object.

<al-for iter="item" expr="list">

   <al-exec expr="real=item.value()>
   <al-value expr="real.status">

</al-for>

In the example above, we extract the real object from item and then make 
accessible for ordinary use.




More information about the Albatross-users mailing list