Commits

Robert Brewer committed 273d7b7

cherrypy.tree.mount_points now includes {"/": cherrypy.root} even if tree.mount is never called.

Comments (0)

Files changed (3)

     """
     
     def __init__(self):
-        self.mount_points = {}
+        self._mount_points = {}
+    
+    def _get_mount_points(self):
+        m = self._mount_points
+        if "/" not in m:
+            import cherrypy
+            if not isinstance(cherrypy.root, Root):
+                m["/"] = cherrypy.root
+        return m
+    def _set_mount_points(self, newvalue):
+        self._mount_points = newvalue
+    mount_points = property(_get_mount_points, _set_mount_points)
     
     def mount(self, app_root, baseurl=None, conf=None):
         """Mount the given app_root at the given baseurl (relative to root)."""

cherrypy/test/helper.py

         # Must run each module in a separate suite,
         # because each module uses/overwrites cherrypy globals.
         cherrypy.root = None
+        cherrypy.tree = cherrypy._cptree.Tree()
         cherrypy.config.reset()
         setConfig(conf)
         

cherrypy/test/test_core.py

         cherrypy.config.update({'server.default_content_type': 'text/plain'})
         self.getPage('/')
         self.assertHeader('Content-Type', 'text/plain')
+    
+    def testTreeBackwardCompatibility(self):
+        self.assertEqual(cherrypy.tree.mount_points, {"/": cherrypy.root})
+
 
 if __name__ == '__main__':
     helper.testmain()