From d5a13ae1ca51c4955f39be50ed02e987d1c8c3cb Mon Sep 17 00:00:00 2001 From: Stein Magnus Jodal Date: Sat, 4 Jun 2011 18:55:54 +0200 Subject: [PATCH] Add auth_required=True to handle_request, and add it to the MpdCommand object stashed in mpd_commands --- mopidy/frontends/mpd/protocol/__init__.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/mopidy/frontends/mpd/protocol/__init__.py b/mopidy/frontends/mpd/protocol/__init__.py index 24ce1cac..dc6cfb89 100644 --- a/mopidy/frontends/mpd/protocol/__init__.py +++ b/mopidy/frontends/mpd/protocol/__init__.py @@ -22,11 +22,11 @@ LINE_TERMINATOR = u'\n' #: The MPD protocol version is 0.16.0. VERSION = u'0.16.0' -MpdCommand = namedtuple('MpdCommand', ['name']) +MpdCommand = namedtuple('MpdCommand', ['name', 'auth_required']) mpd_commands = set() request_handlers = {} -def handle_request(pattern): +def handle_request(pattern, auth_required=True): """ Decorator for connecting command handlers to command requests. @@ -47,7 +47,8 @@ def handle_request(pattern): def decorator(func): match = re.search('([a-z_]+)', pattern) if match is not None: - mpd_commands.add(MpdCommand(name=match.group())) + mpd_commands.add( + MpdCommand(name=match.group(), auth_required=auth_required)) if pattern in request_handlers: raise ValueError(u'Tried to redefine handler for %s with %s' % ( pattern, func))