@@ -1687,25 +1687,18 @@ def menu(self, size=None, height=None, showid=0, additional=[],
16871687 return '\n ' .join (l )
16881688# def checklist(self, ...)
16891689
1690- class MultilinkIterator :
1691- def __init__ (self , classname , client , values ):
1692- self .classname = classname
1693- self .client = client
1694- self .values = values
1695- self .id = - 1
1696- def next (self ):
1697- '''Return the next item, but skip inaccessible items.'''
1698- check = self .client .db .security .hasPermission
1699- userid = self .client .userid
1700- while 1 :
1701- self .id += 1
1702- if self .id >= len (self .values ):
1703- raise StopIteration
1704- value = self .values [self .id ]
1705- if check ('View' , userid , self .classname , itemid = value ):
1706- return HTMLItem (self .client , self .classname , value )
1707- def __iter__ (self ):
1708- return self
1690+
1691+ def multilinkGenerator (classname , client , values ):
1692+ id = - 1
1693+ check = client .db .security .hasPermission
1694+ userid = client .userid
1695+ while 1 :
1696+ id += 1
1697+ if id >= len (values ):
1698+ raise StopIteration
1699+ value = values [id ]
1700+ if check ('View' , userid , classname , itemid = value ):
1701+ yield HTMLItem (client , classname , value )
17091702
17101703
17111704class MultilinkHTMLProperty (HTMLProperty ):
@@ -1733,15 +1726,15 @@ def __getattr__(self, attr):
17331726 def __iter__ (self ):
17341727 ''' iterate and return a new HTMLItem
17351728 '''
1736- return MultilinkIterator (self ._prop .classname , self ._client ,
1729+ return multilinkGenerator (self ._prop .classname , self ._client ,
17371730 self ._value )
17381731
17391732 def reverse (self ):
17401733 ''' return the list in reverse order
17411734 '''
17421735 l = self ._value [:]
17431736 l .reverse ()
1744- return MultilinkIterator (self ._prop .classname , self ._client , l )
1737+ return multilinkGenerator (self ._prop .classname , self ._client , l )
17451738
17461739 def sorted (self , property ):
17471740 ''' Return this multilink sorted by the given property '''
0 commit comments