diff options
author | Andrew Laski <andrew.laski@rackspace.com> | 2013-01-30 16:25:25 -0500 |
---|---|---|
committer | Andrew Laski <andrew.laski@rackspace.com> | 2013-01-30 16:25:25 -0500 |
commit | 393738860481119a2089d0acbb090611f7ba5bb3 (patch) | |
tree | f393317690936aea9d187fa087f8df60f780d3a4 /nova/test.py | |
parent | 0ff3fe079aeb853ee08afb757156d4a20d74010f (diff) | |
download | nova-393738860481119a2089d0acbb090611f7ba5bb3.tar.gz nova-393738860481119a2089d0acbb090611f7ba5bb3.tar.xz nova-393738860481119a2089d0acbb090611f7ba5bb3.zip |
Extend extension_authorizer to enable cleaner code.
I have seen and used two different methods for authorizing multiple
methods in a class, and both use code duplication that won't be
necessary with this patch.
The first method involves creating multiple authorizers, which can get
out of hand quickly. i.e.:
authorize_attach_index = extensions.extension_authorizer('compute',
'volume_attachments:index')
authorize_attach_show = extensions.extension_authorizer('compute',
'volume_attachments:show')
The second method involves creating an intermediate method in the
extension like:
def authorize(context, action_name):
action = 'os-networksv2:%s' % action_name
extensions.extension_authorizer('compute', action)(context)
but this ends up getting duplicated in each file. This patch allows
extensions to use the authorizers they already have but gives them finer
control by passing something like "action='index'" to the authorizer.
Change-Id: I6371b2c631acc9345ee6ca4672afa1f49781f22b
Diffstat (limited to 'nova/test.py')
0 files changed, 0 insertions, 0 deletions