[albatross-users] more data tricks for the wiki

Matt Goodall matt at pollenation.net
Thu Jul 3 11:40:38 EST 2003


I have added a "Examples of using <al-for>" item to RequestsForContent
for now. If I had more time I would have added the whole thing ... work
always gets in the way!

I'm probably being a bit pedantic but ...

Strictly speaking, ListIterator.value() *always* returns a reference to
a list item, it never returns the value. The reason it appears that the
value is being returned for a string, integer, float etc is that those
objects know how to display themselves as text.

Note that one of the 2.x Python releases changed even the basic types
into objects so there is literally no difference between a string and a
type you define using "class" these days.

And while I'm being pedantic ;-) ... ListIterator contains a list, not a
list item. It steps through the list when next() is called and returns a
reference to the current item when value() is called.

Cheers, Matt


On Thu, 2003-07-03 at 01:29, Eric S. Johansson wrote:
> 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.
> 
> _______________________________________________
> Albatross-users mailing list
> Albatross-users at object-craft.com.au
> https://www.object-craft.com.au/cgi-bin/mailman/listinfo/albatross-users
-- 
Matt Goodall, Pollenation Internet Ltd
w: http://www.pollenation.net
e: matt at pollenation.net
t: 0113 2252500



More information about the Albatross-users mailing list