Skip to content

Commit

Permalink
tweak decorators to handle non-API methods
Browse files Browse the repository at this point in the history
remove @needs_caller_key; fold into cbui_url()
  • Loading branch information
disruptek committed Sep 2, 2012
1 parent 4bc81b5 commit b54a08a
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions boto/fps/connection.py
Expand Up @@ -63,7 +63,7 @@ def wrapper(*args, **kw):
if 1 != len(filter(hasgroup, groups)):
message = ' OR '.join(['+'.join(g) for g in groups])
message = "{0} requires {1} argument(s)" \
"".format(func.action, message)
"".format(getattr(func, 'action', 'Method'), message)
raise KeyError(message)
return func(*args, **kw)
message = ' OR '.join(['+'.join(g) for g in groups])
Expand All @@ -83,16 +83,6 @@ def wrapper(*args, **kw):
return add_attrs_from(func, to=wrapper)


def needs_caller_key(func):

def wrapper(self, *args, **kw):
kw.setdefault('callerKey', self.aws_access_key_id)
return func(self, *args, **kw)
wrapper.__doc__ = "{0}\nUses callerKey, defaults to your " \
"AWS Access Key ID".format(func.__doc__)
return add_attrs_from(func, to=wrapper)


def api_action(*api):

def decorator(func):
Expand Down Expand Up @@ -193,7 +183,6 @@ def install_payment_instruction(self, action, response, **kw):
"""
return self.get_object(action, kw, response)

@needs_caller_key
@needs_caller_reference
@requires(['returnURL', 'pipelineName'])
def cbui_url(self, **kw):
Expand All @@ -211,6 +200,7 @@ def cbui_url(self, **kw):
'signatureMethod': 'HmacSHA256',
'signatureVersion': '2',
})
kw.setdefault('callerKey', self.aws_access_key_id)

safestr = lambda x: x is not None and str(x) or ''
safequote = lambda x: urllib.quote(safestr(x), safe='~')
Expand Down

0 comments on commit b54a08a

Please sign in to comment.