> I am working on a product in which one of the objects keeps an array. I've
> already overcome the problems with making the array persistent (i.e. by not
> using .append, but intead re-assigning the array each time). Anyway...I
> digress..

This sounds a bit awkward, if you could post some of the code (or release an
alpha version of your product, that'd give us a context..).

> This prints out the id of each of my objects. But I ALSO want to print out the
> contents of the array, indented after each instances id. What is the best way > to 
>do this in DTML? Is there as way? Lets say for arguments sake that each
> array element is a string, how do I iterate through the array and print the
> strings.

If your class is defined somewhere along these lines:

class myclass(Persistent,

   def __init__(self, id, body):

       self.id        self.body 
you could easiliy display the body of the object within the dtml-in loop using
the same approach as with with id, <dtml-var body>.

If you're wondering how to display _the entire object_, then defining a __call__ would 
probably be the right thing, and you could do the loop like this:

<dtml-in "objectValues('My object')">
    <dtml-var sequence-item>

> Lets say each element in the array is anothe array (of 5 elements), How do
> I loop over the array and pull out the sub arrays and print those five
> elements?

Easy enough:

<dtml-in "objectValues('My object')">
     <dtml-in "_['sequence-item'].sequence_like_object">
             This is the contents of one of the array elements contained within
             an object with meta type <dtml-var meta_type>:
             <dtml-var sequence-item>

> Any help/direction would be appreciated, I've checked the docs and refered to
> some sample products but I either missed something obvious (probable) or It's
> hard..or something :-)

Well, hope this helps then.  
I'd also recommend reading the Python tutorial, and other introductory Python 
material, if you're not familiar with it.


Zope maillist  -  [EMAIL PROTECTED]
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-dev )

Reply via email to