[Zope] Re: ZTUtils.Iterator value in ZPT

David Pratt fairwinds at eastlink.ca
Wed Jul 20 10:17:20 EDT 2005


Thanks Tres.  The 1's are explained for sure but I can't see a always 
doing the job for this.  What I need is an object that keeps track of 
the last number given to it so it will supply the next based on its 
state.  For use in a flat form with say a dozen fields you are not 
repeating over each field but still you need an incrementing tabindex 
value. In this case no repeat is necessary but each call to tabindex 
still requires next value and you can't do this if there if state is 
not available. I thought I could use the built-in iterator in this way 
but 1 or 0 for next will not return what I need from the instance.  
Could a method be added to existing Iterator class to provide the 
current or next value of Iterator instance for this purpose as opposed 
to true and false. Maybe called them currval and nextval or similar. I 
hoping not to have to create a product just to do this.

Regards
David


On Wednesday, July 20, 2005, at 10:24 AM, Tres Seaver wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> David Pratt wrote:
>> Hi Chris. Thanks for your reply.
>>
>> My understanding (which may be flawed) is that ZTUtils iterator 
>> provides
>> values of a sequence as you iterate over them with a repeat statement.
>> I believe what I am trying to do is sensible.  I have looked at the 
>> api
>> and can't seem to get the right magic using the methods  provided.
>> Tabindex for forms keeps track of tab position so when you use tab key
>> it moves the cursor to next field tabindex in form .  So if I have 5
>> input fields from top to bottom, I want to define an iterator object,
>> and obtain the next number in the iterator when zpt does its thing to
>> create the form so that I would have a tabindex starting at 1 and next
>> field value would be 2, then 3 etc.
>>
>> A range by itself doesn't do the trick since it provides all values to
>> the variable where I am looking only for a single number incremented 
>> to
>> the next value.
>
> - From $ZOPE/lib/python/ZTUtils/Iterator:
>
>  __doc__='''Iterator class
>
>  Unlike the builtin iterators of Python 2.2+, these classes are
>  designed to maintain information about the state of an iteration.
>  The Iterator() function accepts either a sequence or a Python
>  iterator.  The next() method fetches the next item, and returns
>  true if it succeeds.
>
>  $Id: Iterator.py,v 1.9.42.2 2003/11/04 19:27:43 evan Exp $'''
>
>
> Note that last sentence, which explains why you are seeing the '1' 
> value
> everywere.  'tal:repeat' over a range should get you what you want;  I
> don't think you *need* an iterator for your use case.
>
>
> Tres.
> - --
> ===================================================================
> Tres Seaver          +1 202-558-7113          tseaver at palladion.com
> Palladion Software   "Excellence by Design"    http://palladion.com
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.2.5 (GNU/Linux)
> Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
>
> iD8DBQFC3lB++gerLs4ltQ4RAuvSAJwPRCNefT9753fli0xOL7EEnRRHgwCggT/C
> M3ysckA7tZJZkZ0I10xgkLI=
> =jzat
> -----END PGP SIGNATURE-----
>


More information about the Zope mailing list