Can I contribute a small TabindexIterator class for ZTUtils. It is not big, but handy for generating tabindex values in a site. The current Iterator class available was not meant to do this but this is. I think this could be added to Iterators.py It seems better to incorporate something like this in ZTUtils than making a site tool to do this.

It only provides one method next() and takes a sequence. If you want your tabindex to start at 500 and go no further than 599, you just give it range(500,600) and stops iterating. For for 0 to n - just use range(n). It could always pass after iteration stops but I think it is better to raise exception so you can modify your sequence, if necessary.


class TabindexIterator:
        """ Tabindex iterator class """
        
        __allow_access_to_unprotected_subobjects__ = 1
        
        def __init__(self, seq):                
                self.iter = seq.__iter__()
                
        def next(self):
                try:
                        next = self.iter.next()
                        return next
                except StopIteration:
                        raise 'Tabindex iterator exhausted.'

Regards,
David
_______________________________________________
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - http://mail.zope.org/mailman/listinfo/zope-announce
http://mail.zope.org/mailman/listinfo/zope-dev )

Reply via email to