Mercurial > p > roundup > code
comparison 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 |
comparison
equal
deleted
inserted
replaced
| 5394:c26d88ec071e | 5395:23b8e6067f7c |
|---|---|
| 327 try: | 327 try: |
| 328 cls = self.db.getclass(prop.classname) | 328 cls = self.db.getclass(prop.classname) |
| 329 except KeyError: | 329 except KeyError: |
| 330 return 0 | 330 return 0 |
| 331 props = dict.fromkeys(('id', cls.labelprop(), cls.orderprop())) | 331 props = dict.fromkeys(('id', cls.labelprop(), cls.orderprop())) |
| 332 for p in props.iterkeys(): | 332 for p in props.keys(): |
| 333 for perm in perms: | 333 for perm in perms: |
| 334 if perm.searchable(prop.classname, p): | 334 if perm.searchable(prop.classname, p): |
| 335 break | 335 break |
| 336 else: | 336 else: |
| 337 return 0 | 337 return 0 |
| 411 # filterspec or sort/group list | 411 # filterspec or sort/group list |
| 412 | 412 |
| 413 def filterFilterspec(self, userid, classname, filterspec): | 413 def filterFilterspec(self, userid, classname, filterspec): |
| 414 """ Return a filterspec that has all non-allowed properties removed. | 414 """ Return a filterspec that has all non-allowed properties removed. |
| 415 """ | 415 """ |
| 416 return dict ([(k, v) for k, v in filterspec.iteritems() | 416 return dict ([(k, v) for k, v in filterspec.items() |
| 417 if self.hasSearchPermission(userid,classname,k)]) | 417 if self.hasSearchPermission(userid,classname,k)]) |
| 418 | 418 |
| 419 def filterSortspec(self, userid, classname, sort): | 419 def filterSortspec(self, userid, classname, sort): |
| 420 """ Return a sort- or group-list that has all non-allowed properties | 420 """ Return a sort- or group-list that has all non-allowed properties |
| 421 removed. | 421 removed. |
