Skip to content

Commit 8e9b685

Browse files
author
Richard Jones
committed
merge from HEAD
1 parent b06cdf5 commit 8e9b685

File tree

2 files changed

+19
-21
lines changed

2 files changed

+19
-21
lines changed

CHANGES.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
This file contains the changes to the Roundup system over time. The entries
22
are given with the most recent entry first.
33

4+
2005-??-?? 0.8.1
5+
Fixed:
6+
- replaced MutlilinkIterator with multilinkGenerator (thanks Bob Ippolito)
7+
8+
49
2005-02-16 0.8.0
510
Fixed:
611
- fix roundup-server log and PID file paths to be absolute

roundup/cgi/templating.py

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -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

17111704
class 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

Comments
 (0)