Пример #1
0
 def test_sorting_of_traversals(self):
     user_dict = self.narrowedConfig['wat']['fields']
     trav_dict = self.traversalConfig['wat']['fields']
     print '\n'
     print 'Sorts traversals the user is allowed to execute.'
     print 'User dictionary: %s' % user_dict
     print 'Traversal dictionary: %s' % trav_dict
     sorted_traversals = permit._sorted_traversals(trav_dict, user_dict)
     print sorted_traversals
     self.assertIn('baz', sorted_traversals['many'])
Пример #2
0
def sorted_traversals(resource=None, config=None):
    """ A resource to look up, and a pre-narrowed config.

    We'll go get the traversal permissions, scope both configs,
    and send them off to the be sorted. The result will have
    the valid traversals for this user sorted into 'one', 'many'
    and 'parent'.
    """

    return _sorted_traversals(
        TRAVERSAL_PERMISSIONS[resource]['fields'],
        config[resource]['fields']
        )