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

Changeset 947

Show
Ignore:
Timestamp:
01/27/06 06:16:46
Author:
rdelon
Message:

Added "cherrypy.lowercase_api" switch so that users can say "I'm using the new lowercase API" and get a (small) speed boost from it.

Files:

Legend:

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

    r939 r947  
    1515# Legacy code may clobber this. 
    1616root = None 
     17 
     18lowercase_api = False 
    1719 
    1820import _cpserver 
  • trunk/cherrypy/config.py

    r913 r947  
    116116            path = "/" 
    117117         
    118         try: 
    119             result = configs[path][_cputil.lower_to_camel(key)] 
    120             break 
    121         except KeyError: 
     118        if cherrypy.lowercase_api is False: 
     119            # We don't know for sure if user uses the new lowercase API 
     120            try: 
     121                result = configs[path][_cputil.lower_to_camel(key)] 
     122                break 
     123            except KeyError: 
     124                try: 
     125                    result = configs[path][key] 
     126                    break 
     127                except KeyError: 
     128                    pass 
     129                pass 
     130             
     131            try: 
     132                # Check for a server.environment entry at this node. 
     133                env = configs[path]["server.environment"] 
     134                # For backward compatibility, check for camelCase key first 
     135                result = environments[env][_cputil.lower_to_camel(key)] 
     136                break 
     137            except KeyError: 
     138                try: 
     139                    env = configs[path]["server.environment"] 
     140                    result = environments[env][key] 
     141                    break 
     142                except KeyError: 
     143                    pass 
     144                pass 
     145        else: 
     146            # We know for sure that user uses the new lowercase api 
    122147            try: 
    123148                result = configs[path][key] 
     
    125150            except KeyError: 
    126151                pass 
    127             pass 
    128          
    129         try: 
    130             # Check for a server.environment entry at this node. 
    131             env = configs[path]["server.environment"] 
    132             # For backward compatibility, check for camelCase key first 
    133             result = environments[env][_cputil.lower_to_camel(key)] 
    134             break 
    135         except KeyError: 
     152             
    136153            try: 
    137154                env = configs[path]["server.environment"] 
     
    141158                pass 
    142159            pass 
    143          
     160 
    144161        if path == "global": 
    145162            result = default_value 
  • trunk/cherrypy/filters/__init__.py

    r911 r947  
    9999    special_methods = [] 
    100100    for f in _cputil.get_special_attribute("_cp_filters", "_cpFilterList"): 
    101         # Try old name first 
    102         old_method_name = backward_compatibility_dict.get(method_name) 
    103         method = getattr(f, old_method_name, None) 
    104         if (method is None): 
     101        if cherrypy.lowercase_api is False: 
     102            # Try old name first 
     103            old_method_name = backward_compatibility_dict.get(method_name) 
     104            method = getattr(f, old_method_name, None) 
     105            if (method is None): 
     106                method = getattr(f, method_name, None) 
     107            if method: 
     108                special_methods.append(method) 
     109        else: 
     110            # We know for sure that user uses the new lowercase API 
    105111            method = getattr(f, method_name, None) 
    106         if method: 
    107             special_methods.append(method) 
     112            if method: 
     113                special_methods.append(method) 
    108114     
    109115    if method_name in _input_methods: 

Hosted by WebFaction

Log in as guest/cpguest to create tickets