Download Install Tutorial Docs FAQ Tools WikiLicense Team IRC Planet Involvement Shop Book

Changeset 985

Show
Ignore:
Timestamp:
03/01/06 09:20:19
Author:
dowski
Message:

Fix for #457. Custom filters placed in server.input_filters and server.ouput_filters now get checked for the presence of the old camelCase filter hooks at initialization for backward compatibility with 2.1.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/cherrypy/filters/__init__.py

    r947 r985  
    3636_output_methods = ['before_finalize', 'on_end_resource', 'on_end_request', 
    3737        'before_error_response', 'after_error_response'] 
     38 
     39_old_input_methods = ['onStartResource', 'beforeRequestBody', 'beforeMain'] 
     40_old_output_methods = ['beforeFinalize', 'onEndResource', 'onEndRequest', 
     41        'beforeErrorResponse', 'afterErrorResponse'] 
    3842 
    3943backward_compatibility_dict = { 
     
    7781     
    7882    # Transform the instance lists into a dict of methods 
     83    # in 2.2 we check the old camelCase filter names first 
     84    # to provide backward compatibility with 2.1 
    7985    _filterhooks.clear() 
    80     for name in _input_methods
    81         _filterhooks[name] = [] 
     86    for old_name, new_name in zip(_old_input_methods, _input_methods)
     87        _filterhooks[new_name] = [] 
    8288        for f in inputs: 
    83             method = getattr(f, name, None) 
     89            method = getattr(f, old_name, None) 
    8490            if method: 
    85                 _filterhooks[name].append(method) 
    86     for name in _output_methods: 
    87         _filterhooks[name] = [] 
     91                _filterhooks[new_name].append(method) 
     92            else: 
     93                method = getattr(f, new_name, None) 
     94                if method: 
     95                    _filterhooks[new_name].append(method) 
     96    for old_name, new_name in zip(_old_output_methods, _output_methods): 
     97        _filterhooks[new_name] = [] 
    8898        for f in outputs: 
    89             method = getattr(f, name, None) 
     99            method = getattr(f, old_name, None) 
    90100            if method: 
    91                 _filterhooks[name].append(method) 
     101                _filterhooks[new_name].append(method) 
     102            else: 
     103                method = getattr(f, new_name, None) 
     104                if method: 
     105                    _filterhooks[new_name].append(method) 
    92106 
    93107 

Hosted by WebFaction

Log in as guest/cpguest to create tickets