Anonymous avatar Anonymous committed c5607f6

Now using 'global' for the main config key. ('/' still works but 'global' is the default). Still need to update the docs

Comments (0)

Files changed (16)

cherrypy/_cpconfig.py

     
     'sessionFilter.new': 'sessionMap', # legacy setting
     }
-configMap = {"/": defaultGlobal.copy()}
+configMap = {"global": defaultGlobal.copy()}
 
 def update(updateMap=None, file=None):
     if updateMap:
         for section, valueMap in updateMap.items():
+            if not isinstance(valueMap, dict):
+                # Shortcut syntax
+                #   ex: update({'server.socketPort': 80})
+                valueMap = {section: valueMap}
+                section = 'global'
             s = configMap.get(section)
             if not s:
                 configMap[section] = valueMap
 def get(key, defaultValue=None, returnSection=False, startPath = None):
     # Look, ma, no Python function calls! Uber-fast.
     # start path lest you overload the starting search path (needed by getAll)
-    
     global cpg
     if not cpg:
         import cpg
         try:
             result = configMap[path][key]
         except KeyError:
-            if path != "/":
+            if path not in ("/", "global"):
                 i = path.rfind("/")
                 if i < 0:
                     result = defaultValue
                 else:
                     path = path[:i]
                     continue
+            elif path != "global":
+                path = "global"
+                continue
             else:
                 result = defaultValue
         break
     
     if returnSection:
+        if path == 'global':
+            return '/'
         return path
     else:
         return result

cherrypy/lib/profiler.py

 def serve(path=None, port=8080):
     from cherrypy import cpg
     cpg.root = Profiler(path)
-    cpg.config.update({'/': {'server.serverPort': port,
+    cpg.config.update({'global': {'server.serverPort': port,
                              'server.threadPool': 10,
                              'server.environment': "production",
                              'session.storageType': "ram",

cherrypy/test/test.py

         print
         print "Running tests:", name
         
-        cpg.config.update({'/': server_conf.copy()})
+        cpg.config.update({'global': server_conf.copy()})
         helper.startServer(server)
         for testmod in testList:
             # Must run each module in a separate suite,
             # because each module uses/overwrites cpg globals.
             cpg.config.configMap.clear()
-            cpg.config.configMap["/"] = cpg.config.defaultGlobal.copy()
-            cpg.config.update({'/': server_conf.copy()})
+            cpg.config.configMap["global"] = cpg.config.defaultGlobal.copy()
+            cpg.config.update({'global': server_conf.copy()})
             suite = CPTestLoader.loadTestsFromName(testmod)
             CPTestRunner(verbosity=2).run(suite)
         helper.stopServer()

cherrypy/test/test_baseurl_filter.py

 
 cpg.root = Root()
 cpg.config.update({
-    '/': {
+    'global': {
         'server.environment': 'production',
         'baseUrlFilter.on': True,
         'baseUrlFilter.baseUrl': 'http://www.mydomain.com'

cherrypy/test/test_cache_filter.py

 
 cpg.root = Root()
 cpg.config.update({
-    '/': {
+    'global': {
         'server.logToScreen': False,
         'server.environment': 'production',
         'cacheFilter.on': True,

cherrypy/test/test_combinedfilters.py

 
 cpg.root = Root()
 cpg.config.update({
-    '/': {
+    'global': {
         'server.logToScreen': False,
         'server.environment': 'production',
         'gzipFilter.on': True,

cherrypy/test/test_core.py

 
 
 cpg.config.update({
-    '/': {
+    'global': {
         'server.logToScreen': False,
         'server.environment': 'production',
         'foo': 'this',

cherrypy/test/test_decodingencoding_filter.py

 
 cpg.root = Root()
 cpg.config.update({
-    '/': {
+    'global': {
         'server.logToScreen': False,
         'server.environment': 'production',
         'encodingFilter.on': True,

cherrypy/test/test_gzip_filter.py

 
 cpg.root = Root()
 cpg.config.update({
-    '/': {
+    'global': {
         'server.logToScreen': False,
         'server.environment': 'production',
         'gzipFilter.on': True,

cherrypy/test/test_logdebuginfo_filter.py

 
 cpg.root = Root()
 cpg.config.update({
-    '/': {
+    'global': {
         'session.storageType': 'ram',
         'session.timeout': 60,
         'session.cleanUpDelay': 60,

cherrypy/test/test_objectmapping.py

 cpg.root.dir1.dir2.dir3 = Dir3()
 cpg.root.dir1.dir2.dir3.dir4 = Dir4()
 cpg.config.update({
-    '/': {
+    'global': {
         'server.logToScreen': False,
     }
 })

cherrypy/test/test_static_filter.py

 
 cpg.root = Root()
 cpg.config.update({
-    '/': {
+    'global': {
         'staticFilter.on': False,
         'server.logToScreen': False,
         'server.environment': 'production',

cherrypy/test/test_tutorials.py

 def load_tut_module(tutorialName):
     """Import or reload tutorial module as needed."""
     cpg.config.configMap.clear()
-    cpg.config.configMap["/"] = cpg.config.defaultGlobal.copy()
-    cpg.config.update({'/': server_conf.copy()})
+    cpg.config.configMap["global"] = cpg.config.defaultGlobal.copy()
+    cpg.config.update({'global': server_conf.copy()})
     
     target = "cherrypy.tutorial." + tutorialName
     if target in sys.modules:
     
     def test08Sessions(self):
         load_tut_module("tut08_sessions")
-        cpg.config.update({"/": {"sessionFilter.on": True}})
+        cpg.config.update({"global": {"sessionFilter.on": True}})
         
         helper.request('/')
         self.assertEqual(cpg.response.body,
     
     def test10SessionFilter(self):
         load_tut_module("tut10_sessionfilter")
-        cpg.config.update({"/": {"sessionFilter.on": True}})
+        cpg.config.update({"global": {"sessionFilter.on": True}})
         
         helper.request('/')
         self.assert_("viewed this page 1 times" in cpg.response.body)

cherrypy/test/test_virtualhost_filter.py

 
 cpg.root = Root()
 cpg.config.update({
-    '/': {
+    'global': {
         'server.logToScreen': False,
         'server.environment': 'production',
         'virtualHostFilter.on': True,

cherrypy/tutorial/tut08_sessions.py

 
 
 cpg.root = HitCounter()
-cpg.config.update({'/': {'sessionFilter.on': True}})
+cpg.config.update({'global': {'sessionFilter.on': True}})
 
 if __name__ == '__main__':
     cpg.config.update(file = 'tutorial.conf')

cherrypy/tutorial/tutorial.conf

-[/]
+[global]
 server.socketPort = 8080
 server.threadPool = 10
 server.environment = "production"
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.