Commits

Anonymous committed 3081147

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.

Comments (0)

Files changed (3)

cherrypy/__init__.py

 # Legacy code may clobber this.
 root = None
 
+lowercase_api = False
+
 import _cpserver
 server = _cpserver.Server()
 

cherrypy/config.py

         if path == "":
             path = "/"
         
-        try:
-            result = configs[path][_cputil.lower_to_camel(key)]
-            break
-        except KeyError:
+        if cherrypy.lowercase_api is False:
+            # We don't know for sure if user uses the new lowercase API
+            try:
+                result = configs[path][_cputil.lower_to_camel(key)]
+                break
+            except KeyError:
+                try:
+                    result = configs[path][key]
+                    break
+                except KeyError:
+                    pass
+                pass
+            
+            try:
+                # Check for a server.environment entry at this node.
+                env = configs[path]["server.environment"]
+                # For backward compatibility, check for camelCase key first
+                result = environments[env][_cputil.lower_to_camel(key)]
+                break
+            except KeyError:
+                try:
+                    env = configs[path]["server.environment"]
+                    result = environments[env][key]
+                    break
+                except KeyError:
+                    pass
+                pass
+        else:
+            # We know for sure that user uses the new lowercase api
             try:
                 result = configs[path][key]
                 break
             except KeyError:
                 pass
-            pass
-        
-        try:
-            # Check for a server.environment entry at this node.
-            env = configs[path]["server.environment"]
-            # For backward compatibility, check for camelCase key first
-            result = environments[env][_cputil.lower_to_camel(key)]
-            break
-        except KeyError:
+            
             try:
                 env = configs[path]["server.environment"]
                 result = environments[env][key]
             except KeyError:
                 pass
             pass
-        
+
         if path == "global":
             result = default_value
             break

cherrypy/filters/__init__.py

     """Execute the given method for all registered filters."""
     special_methods = []
     for f in _cputil.get_special_attribute("_cp_filters", "_cpFilterList"):
-        # Try old name first
-        old_method_name = backward_compatibility_dict.get(method_name)
-        method = getattr(f, old_method_name, None)
-        if (method is None):
+        if cherrypy.lowercase_api is False:
+            # Try old name first
+            old_method_name = backward_compatibility_dict.get(method_name)
+            method = getattr(f, old_method_name, None)
+            if (method is None):
+                method = getattr(f, method_name, None)
+            if method:
+                special_methods.append(method)
+        else:
+            # We know for sure that user uses the new lowercase API
             method = getattr(f, method_name, None)
-        if method:
-            special_methods.append(method)
+            if method:
+                special_methods.append(method)
     
     if method_name in _input_methods:
         # Run special filters after defaults.
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.