From b0821e8011f6ff8ce25978bf98e76e4c36d15c96 Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Mon, 12 Feb 2018 15:32:54 -0600 Subject: [PATCH] More tweaks for python 3 --- tailbone/views/batch/core.py | 2 +- tailbone/views/principal.py | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/tailbone/views/batch/core.py b/tailbone/views/batch/core.py index ea595e8e..5b5511da 100644 --- a/tailbone/views/batch/core.py +++ b/tailbone/views/batch/core.py @@ -30,7 +30,7 @@ import os import datetime import logging import tempfile -from cStringIO import StringIO +from six import StringIO import six import sqlalchemy as sa diff --git a/tailbone/views/principal.py b/tailbone/views/principal.py index dd82522b..23ad27cb 100644 --- a/tailbone/views/principal.py +++ b/tailbone/views/principal.py @@ -48,6 +48,10 @@ class PrincipalMasterView(MasterView): '/principal/{}.mako'.format(template), ] + super(PrincipalMasterView, self).get_fallback_templates(template, mobile=mobile) + def perm_sortkey(self, item): + key, value = item + return value['label'].lower() + def find_by_perm(self): """ View for finding all users who have been granted a given permission @@ -55,9 +59,9 @@ class PrincipalMasterView(MasterView): permissions = copy.deepcopy(self.request.registry.settings.get('tailbone_permissions', {})) # sort groups, and permissions for each group, for UI's sake - sorted_perms = sorted(permissions.items(), key=lambda (k, v): v['label'].lower()) + sorted_perms = sorted(permissions.items(), key=self.perm_sortkey) for key, group in sorted_perms: - group['perms'] = sorted(group['perms'].items(), key=lambda (k, v): v['label'].lower()) + group['perms'] = sorted(group['perms'].items(), key=self.perm_sortkey) # group options are stable, permission options may depend on submitted group group_choices = [(gkey, group['label']) for gkey, group in sorted_perms]