Ignore:
Timestamp:
Feb 12, 2011, 11:16:02 PM (10 years ago)
Author:
Ralph Meijer <ralphm@…>
Branch:
default
Message:

Catch KeyError? for unsupported verbs in legacy PubSubService? usage.

Author: ralphm.
Fixes: #70.

Because requests are now parsed by PubSubRequest?, it can happen that a request
is succesfully parsed, but there is no legacy handler available. This used
to raise a KeyError?, resulting in a internal-server-error being returned.
Now it returns a feature-not-implemented error.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • wokkel/pubsub.py

    r93 r94  
    11821182                handler = getattr(resource, request.verb)
    11831183            except AttributeError:
    1184                 # fix lookup feature
    11851184                text = "Request verb: %s" % request.verb
    11861185                return defer.fail(Unsupported('', text))
     
    11881187            d = handler(request)
    11891188        else:
    1190             handlerName, argNames = self._legacyHandlers[request.verb]
     1189            try:
     1190                handlerName, argNames = self._legacyHandlers[request.verb]
     1191            except KeyError:
     1192                text = "Request verb: %s" % request.verb
     1193                return defer.fail(Unsupported('', text))
     1194
    11911195            handler = getattr(self, handlerName)
     1196
    11921197            args = [getattr(request, arg) for arg in argNames]
    11931198            if 'options' in argNames:
    11941199                args[argNames.index('options')] = request.options.getValues()
     1200
    11951201            d = handler(*args)
    11961202
Note: See TracChangeset for help on using the changeset viewer.