Mercurial > p > roundup > code
diff roundup/security.py @ 5395:23b8e6067f7c
Python 3 preparation: update calls to dict methods.
Tool-assisted patch. Changes of iterkeys / itervalues / iteritems to
keys / values / items are fully automated, but may make things less
efficient in Python 2. Automated tools want to add list() around many
calls to keys / values / items, but I thought most such list()
additions were unnecessary because it seemed the result of keys /
values / items was just iterated over while the set of dict keys
remained unchanged, rather than used in a way requiring an actual
list, or used while the set of keys in the dict could change. It's
quite possible I missed some cases where list() was really needed, or
left in some unnecessary list() calls.
In cases where list() was only needed because the resulting list was
then sorted in-place, I changed the code to use calls to sorted().
| author | Joseph Myers <jsm@polyomino.org.uk> |
|---|---|
| date | Tue, 24 Jul 2018 23:04:42 +0000 |
| parents | 35ea9b1efc14 |
| children | 3fa026621f69 |
line wrap: on
line diff
--- a/roundup/security.py Tue Jul 24 23:03:35 2018 +0000 +++ b/roundup/security.py Tue Jul 24 23:04:42 2018 +0000 @@ -329,7 +329,7 @@ except KeyError: return 0 props = dict.fromkeys(('id', cls.labelprop(), cls.orderprop())) - for p in props.iterkeys(): + for p in props.keys(): for perm in perms: if perm.searchable(prop.classname, p): break @@ -413,7 +413,7 @@ def filterFilterspec(self, userid, classname, filterspec): """ Return a filterspec that has all non-allowed properties removed. """ - return dict ([(k, v) for k, v in filterspec.iteritems() + return dict ([(k, v) for k, v in filterspec.items() if self.hasSearchPermission(userid,classname,k)]) def filterSortspec(self, userid, classname, sort):
